You might have changed the WordPress site URL and the home URL from the cPanel using phpMyAdmin. As you might attest, it’s quick and easy to do so. But what about achieving the same feat using the Command Line? In some instances (when you do not have a control panel), admins may turn to the command line to update the site and home URL. In this article, we explain how to do that step-by-step.
Step-by-Step Process
Here are the steps you need to take:
Now you need to follow the steps to change the home URL. Before that, you need to check what is the current home URL. Use this command for to list the option that’s named ‘home’:
To update the home URL, you need to enter the new website URL on option_value””. Execute this command:
This will update your home URL.
Now, lets update the site URL. Before this, learn about the current site URL using this command:
It will return the following results:
Update the site URL using the UPDATE command. Execute this command:
Now your site URL is updated too. So that’s how you update the home and website URL using command line. For further assistance, get in touch with customer support team.
Step-by-Step Process
Here are the steps you need to take:
- Open the wp-config.php file, also known as the WordPress configuration file
- Get MySQL database details like DB_NAME, DB_USER, DB_PASSWORD. Inside the file, look for the following lines:
Code:
define(‘DB_NAME’, ‘myname_wp111’);
define(‘DB_USER’, ‘myuser_wp111’)
define(‘DB_PASSWORD’, ’26)ThePassworde0.9′);
- Then using command line interface, log in to your server and then log in to to the MySQL database prompt
- Once inside the database prompt, execute the following command to view the database:
Code:
mysql> SHOW DATABASES;
- Use the DB_NAME command to select the database “myname_wp111” and update the home and website URL
Code:
mysql> USE DB_NAME;
mysql> USE myname_wp111;
- Database is now changed
- Inside of the database, you need to view all the tables. So use the command -
Code:
SHOW TABLES;
- Then, use the below command which will display all the columns in the wp_options table
Code:
SELECT option_name FROM wp_options;
Code:
mysql> SELECT * FROM wp_options WHERE option_name = ‘home’;
Code:
It will return results similar to this:
+———–+————-+———————–+———-+
| option_id | option_name | option_value | autoload |
+———–+————-+———————–+———-+
| 36 | home | http:// www. webiste_name. com | yes |
+———–+————-+———————–+———-+
1 row in set (0.00 sec)
Code:
UPDATE wp_options SET option_value=”http://www.new_webiste_name.com/” WHERE option_name = “home”;
Now, lets update the site URL. Before this, learn about the current site URL using this command:
Code:
mysql> SELECT * FROM wp_options WHERE option_name = ‘siteurl’;
Code:
+———–+————-+———————–+———-+
| option_id | option_name | option_value | autoload |
+———–+————-+———————–+———-+
| 1 | siteurl | http:// www. webiste_name. com | yes |
+———–+————-+———————–+———-+
1 row in set (0.00 sec)
Code:
wp_options SET option_value=”http://www.new_webiste_name.com/” WHERE option_name = “siteurl”;