Change WordPress Site URL via Command Line MySQL

Here are quick steps to change your WordPress Site URL via the Command Line in MySQL. You might wanna use this approach because of reasons such as:

If the above is you, then you should proceed by logging into your Droplet, if using DigitalOcean via SSH and let’s go via the terminal way:

Log into MySQL

$ mysql -u root -p

Enter your password and proceed to select our database of choice and list all tables in it

mysql> use wordpress;
mysql> show tables;

Next step is to update:

mysql> update wp_options set option_value = 'http://www.correctDomain.name' where option_id = 1;

Check to verify if changes were made:

mysql> select * from wp_options where option_value = 'http://www.correctDomain.name';

You’re done, and simply exit

mysql> \q

Make sure to disable any define('WP_HOME','http://domain.name'); define('WP_SITEURL','http://domain.name'); you have in your wp-config.php file then open up your website and visit your WordPress > Settings > General and you can now have a corrected WordPress website home and site URL.

Exit mobile version