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.

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

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

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


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.