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:
- Begin by connecting to your VPS over SSH.
- 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 example.com, you would use the following command:
- 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: