Not sure what to do when in the console to access the database.

New to this, I’m trying to set up a wordpress site, I have the droplet made, and I think everything set up for it, but on the wordpress installation when everything was done I think I changed the site address url, causing an issue of the page not existing anymore.

I know how to change it, (I think) but I need to access the database. I’m actually not exactly sure what to do when I get there.

I was also told to use phpmyadmin, but again not exactly sure how to use that in conjuction with this droplet.



To access the database via command line (you’re using MySQL, right?), just type the following:

mysql -h localhost -u YOUR_USER YOUR_DATABASE -p Where:

-h: your host (if you are not using localhost, just replace it with the address/IP of your MySQL server) -u: your database username -p: tells MySQL that you want to log in using a password

And press enter, so you’ll be prompted to input your database password.

If everything is ok, you’ll see something like:

mysql >

Here you can input your queries (SELECT, INSERT, SHOW TABLES, etc) normally.

To install/use PHPMyAdmin, you can simply follow this cool tutorial:

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


Another option would be to use Adminer. It’s free, like phpMyAdmin, though instead of a thousand files (nothing against phpMyAdmin, it works, it’s just bulky!), it’s a single file and you’d upload it to your server just like you would a normal PHP file (to a web accessible directory).

Once you’ve uploaded it, browse over to the URI where it’s located and enter in your MySQL database credentials (for your WordPress installation). Once authenticated, you’ll be able to access your database and make the changes needed.

Note: It’s a good idea to rename the file (to something that doesn’t resemble adminer.php) and once your done, delete it (for security) or setup another layer of authentication so that you’re not hit with scanners/bots trying to find it (I see them scanning IP’s and domains often). There’s also a WordPress plugin available for it here, so once you’re back up and running, you can install that plugin and administer your database from the WordPress admin.

You’ve got a couple options…

First, make a note of your MySQL root password. If you’re using the WordPress one-click image this is displayed in the MOTD when you log in via ssh.

1.) Using the CLI The command line MySQL client will allow you to update the web address info for WordPress by doing the following:

mysql -uroot -p

You will now be prompted for your MySQL root password.

Once you enter it you will be in the MySQL client shell (NOTE: All commands in the MySQL CLI must end with a semicolon “;”).

use wordpress;

This tells mysql that you want to work with the database named “wordpress” (this is the default on the one-click image)

UPDATE wp_options set option_value = "" where option_name = "siteurl" OR option_name = "home";

This query will update the siteurl and home fields in the wp configuration in MySQL to the URL you provide.

Once you’re done you can exit the MySQL client by typing:


2.) Installing PHPMyAdmin (This assumes WordPress is running on Apache and not nginx or another web server)

apt-get update
apt-get install phpmyadmin

During the process you’ll be prompted for the MySQL root password and to select a web server (Apache) to auto-configure. Once this has completed you can access phpmyadmin on your droplet at /phpmyadmin

I’ve tested both these options against a fresh WordPress One-Click droplet so you should be all set. Personally I would recommend going with the CLI option over installing phpmyadmin unless you will be working directly with the DB a lot.