It’s not so odd when you aren’t able to log in to your WordPress admin panel, sometimes, a plugin or a wrong setting can be the reason.
In such a situation, you need to check the site’s URL, and as you don’t have access to the dashboard, you need to follow other methods.
For a WordPress beginner, dealing with the core files of a WordPress website can be a little bit tricky, but I am going to walk you through a few straightforward methods.
You would be happy to know; you can change the website URL from your MySQL database. In this tutorial, I am going to cover three different ways to update the site URL.
Two of the methods use cPanel, and one is dependent on the developer skills you have. Let me start.
Use the wp-config.php File to Update the Website URL
You may have known that .htaccess and wp-config.php are the two most important files of a WordPress site. Learning about such files is vital.
The wp-config.php is responsible for building a connection with the website’s data and its database; it consists of all the log in information in the encrypted form.
I hope you know how to edit the file. Follow the steps.
Login to your cPanel account and open the file manager. I am sure; you find it familiar.
Make sure you’re in the public_html directory by navigating to it from the left-hand sidebar of cPanel. Search for the wp-config.php file and right-click to edit.
If you host multiple websites on the same server, you have to find the folder name of your domain and open it to edit the wp-config.php file.
For a primary domain, public_html is the location to search into.
– Add two lines of code and save changes.
Don’t forget to replace the site name with yours. If you don’t want to use cPanel, you can also access the file via FTP.
Use the MySQL Database to Update Settings
As you know, the database consists of the information about you, your login credentials, and everything related to your WordPress website.
All you need is to search for the correct database table and edit the site URL. Let me explains how.
Open the phpMyAdmin from your cPanel account. You can find it under the Databases’ section.
Choose the name of the database from the left-hand sidebar and open the wp_options database table.
Search for the siteurl and home rows, click edit to modify the URLs. You can see a box in front of option_value to fill in the URL.
Click on the Go button to save settings.
It’s as simple as that. Repeat the same editing process for home, and you can see new URL of your website running.
NOTE: It’s important to note that you shouldn’t change the URL until you learn when to change.
This method is also complete. Now, you require to understand the concept of using WP-CLI.
Use WP-CLI to Change Website URL of a WordPress Website
First of all, you need to understand that it’s a techie method, which is for developers. For a non-techie user, it can be hard.
Today, I am only providing you the WP-CLI command to update the URL. Before that, you need to learn how to use it.
Many web hosting companies offer access to SSH, which is used to the command line. If you’re afraid of the black window, you may consider using other two methods.
If you have learned to use WP-CLI, let me show you an example of the command.
wp option update home 'https://yoursite.com' wp optionupdate siteurl 'https://yoursite.com'
Don’t forget to replace the website name with your site name. I hope you know what you’re doing. Run the command to accomplish your task.
Depending on your expertise and the choice, you can pick any of the methods. If you have access to the wp-admin panel, you can directly navigate to Settings>>General and change the URLs.
Using the wp-config.php is one of the most convenient ways because you can either access it using cPanel or FTP server.
WP-CLI can be used only by expert WordPress users.
Check out these top 3 WordPress hosting services:
- Do you need the best wordpress hosting? Check out for our recommendations by clicking here.