Connecting to your Database with WP-CLI

Last Updated -

Using WP-CLI to connect to your database is a great shortcut to otherwise long connection commands. If you need to pass manual database commands to your WordPress database, WP-CLI is a great way to get there. Here's how to do it:

  1. Begin by connecting to your VPS over SSH.
  2. Next, you'll want to access the main directory for the site you want to manage. For example, if the primary domain on your site was, you would use the following command:
    cd ~/sites/
  3. Finally, issue the following WP-CLI command to connect to your database:
     wp db query

You should now be all connected and ready to issue commands to your database. Want more information on WP-CLI and the great things that you can do with it? Check out the following articles:

Related Topics

Pagely is the Managed WordPress Hosting Platform designed to exceed the needs of media, business, and Enterprise customers alike. We help the world's biggest brands scale WordPress.

Copyright © 2006-2017 Pagely, Inc. All rights reserved.
Pagely® and WordPress® are registered trademarks.

Powered by Zendesk