Earlier I set up a development WordPress site that mirrored a live WordPress installation. To do this I dumped the entire WordPress database using mysqldump and then imported it into a new database with mysql. Among other things that needed to be changed I needed to update any links that referenced the live site’s URL with the development site’s URL. Below I provide the command to make such an update to only a matching portion of a column in row located in a MySQL database.
Below are a couple simple steps to update your WordPress blog’s URL. The below is valid if you are simply switching the URL using the same domain or if you are changing the WordPress domain all together. You will run into problems if you do not make sure to update each item.
- Update WordPress SiteURL: In the database table wp_options make sure to change siteurl to the new URL. This should be the first row in the wp_options table.
- Change Blog Address: Under “Settings” and then “General” change the “Blog Address” to the new URL.
To locate and replace a string of text in a file using use the below text.
shell# vi filename
Once in vi use the following:
That will replace any instance of string with new-string.