Change WordPress URL using Command Line?

I accidentally changed my WordPress URL without following the instructions, now I am left with a This site can’t be reached error.
How can I change the URL to be a Linode IP again?

7 Replies

Hi @Pixeltablet,

You can change the site URL of your WordPress website by accessing the WordPress database, finding wp_options, and changing the site URL and home URL.

Next, I'd recommend installing and using the Better Search Replace plugin to help find links to the old site and change them to the new one.

https://photos.app.goo.gl/AyosHESCcXYQEFBF8 Keep getting error syntax error near unexpected token WP_HOME

I also tried to make an A record on my domain settings, but nothing did work.

Hi @Pixeltablet,

Odd, is there any error information that you collected? Try using the SELECT * FROM wp_options; command.

If you are unfamiliar with using MySQL on SSH, I recommend downloading and utilizing MySQL Workbench for a better GUI.

@zample I updated the reply, I will try using MySQL
but first I want to see if the SELECT * FROM wp_options; command works.

Hi @Pixeltablet,

Step-by-step instructions on changing the WordPress URL via SSH commands.

mysql -u root -p
(Using this command accesses MySQL)

USE mywordpress_database
(Using this command selects a database)

SELECT * FROM wp_options;
(Using this command shows what's inside of the database)

SELECT option_name, option_value FROM wp_options WHERE option_name IN ('siteurl', 'home');
(Using this command shows the values of the options siteurl and home)

UPDATE wp_options SET option_value='http://mywebsite.com' WHERE option_name='siteurl';
(This command updates siteurl with the link in the option_value)

UPDATE wp_options SET option_value='http://mywebsite.com' WHERE option_name='home';
(This command updates home with the link in the option_value)

Now, recheck the values to see if the changes have been set.

SELECT option_name, option_value FROM wp_options WHERE option_name IN ('siteurl' 'home');

That's the general breakdown.

@zample For some reason I keep getting: command not found
whenever i try to type USE mywordpress_database
I tried LISH and SSH and they both dont work
https://photos.app.goo.gl/x76FCbbHGTGRcRWU9 <-- Proof

Hi @Pixeltablet,

I've added an extra step to my previous reply. Make sure to replace the mywordpress_database with your actual database name. If you left the options on the marketplace deployment page blank, they are set to default, as listed below.

Default WordPress Database Name & User: wordpress


Additional Guides

Deploy WordPress through the Linode Marketplace

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct