You may have noticed, when transferring a website, that the URL is still stuck on the old site even though you have changed the virtual host file to reflect the new domain name. Or you may see the URL entirely greyed out in your WordPress portal. This mismatch can happen if you can’t change the URL within WordPress to reflect the new site name. In this tutorial, we will show you how to change the URL through the database.
Step 1: Enter the Database
If you don’t have your database credentials you can certainly grab them from your wp-config.php file, usually located in /var/www/html. Copy your username and password, you’ll need these to enter phpMyAdmin.
/** MySQL database username */
/** MySQL database password */
If you Ubuntu 14.XX and higher, you can visit https://yourhostname.com/phpmyadmin and enter your database username and password copied from your wp-config.php. CentOS users can usually go to their WHM panel and type in “phpMyAdmin” into the search bar for a shortcut into their database. With specialty platforms like Managed WordPress or Cloud Sites check with your support team to locate your phpMyAdmin instance.
Step 2: Find the WP_Options Table
Once you’ve entered phpMyAdmin, click on your database name on the left, in this case, ours is named 929368_kittens.
Locate wp_options, afterwards you’ll see rows on the right hand side. The home and site_url row is needed as we will be changing these values to the new website name.
Select Edit in the row of siteurl and home to edit the URL, including “http” or “https” (if you already have an SSL on the domain name). Once you’ve changed your URL, select GO to save your changes.
Step 3: Update DNS
Your WordPress instance is now set to your new URL! If you haven’t done so already, you may need to set your A record to your new IP address or clear your browser’s cache to visit your new URL.
Changing the domain name within WordPress is simple enough but sometimes code within an nginx.conf or .htaccess file can also direct a site back to the old domain name. It should also be noted that sometimes a plugin, theme or database can be referenced or hardcoded to read an old domain name. For either problem, the Velvet Blue’s plugin or WP-CLI’s search and replace command cater to the issue. Our Managed WordPress platform performs name changes automatically from our control panel, as well as core updates. Check out how our Managed WordPress product can streamline your work.