2

I apologise in advance for I know that this question has been asked several times already, but being a complete beginner at wordpress coding and database handling, I am still not sure about what those answers really meant. So having just coded a website and converted it into WordPress, I now find myself having to change all of the localhost strings to the accurate ones, but with hundreds to go through, I just wanted to know if any of you were able to recommend a program or technique within PHPMyAdmin (that I may not be aware of) to avoid having to change them one at a time. Thank you all in advance for your time and attention.

0

3 Answers 3

1

First, let me start by saying this is very dangerous, especially for an absolute beginner such as yourself. Please use this with extreme caution as you can potentially bring the entire site down by replacing values in your database with the wrong data.

With that said, there is a script specifically designed for doing search and replace on the WordPress MySQL database. http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

Here's the direct download link: https://github.com/interconnectit/Search-Replace-DB/archive/master.zip

You will extract the folder from the donwloaded zip, then upload the folder to the root of your WordPress install. Once its uploaded just reference the folder in the browser. I always rename the folder to sr (shorthand for search and replace) so its easier to write out the full URL. So as an example, once its in the root of the WordPress install you'd access it like www.example.com/sr/.

After you access the script in the browser, you'll have a GUI with two boxes at the top. The first you'll enter the string you're searching for, and the replace string goes in the second box. Your MySQL details/login should already be populated. After entering your S&R terms scroll down and click "Update Details", then do the "Dry Run" option first. It'll run through the database and show you the values that will be changed. If you are satisfied with the changes, click "Live Run".

Depending on the database size it'll take just a short time to complete. This is the easiest way to S&R the WordPress database.

Important: for security reasons you'll want to delete this folder from your server after you have finished using it. You don't want a database S&R utility just lingering around for no reason.

Another possible option if you're familiar with WP-CLI is to use the wp search-replace command: https://developer.wordpress.org/cli/commands/search-replace/ This would be done through Terminal or another command line utility.

2
  • 1
    Dear AndyWarren, thank you very much for such detailed and precise answer. It all seems very daunting and as you clearly said, easy to mess up, but I just really want to find a better way other than manually changing them one by one (which I have done on several occasions already). Once again thank you ever so much for your really useful help, and I will definitely look into that option
    – user7489286
    Jun 6, 2017 at 7:01
  • @IVIVP You're welcome. Using the first tool in my answer is really quite easy. If you follow the instructions I've listed this should be easy enough for you to accomplish. Once you do it once you'll have it down and will be able to do it any time you need to. I encourage you to try it, but maybe back up your database first just in case. Push yourself to learn and try new things! If this answer helped please do accept it.
    – AndyWarren
    Jun 6, 2017 at 13:07
0

In phpMyAdmin open your table, choose Search > Find and replace. Then specify in which column you want to find and replace, and the original and replacement texts.

2
  • Dear Marc, unfortunately I don't seem to have that option in the search section, for only the following four are available: 'at least one of the words', 'all words', 'the exact phrase' and 'as regular expression', although it is very possible that I may be looking at the wrong place, for as mentioned I have almost no experience in the program. In any case, thank you very much for taking the time to help me out Marc.
    – user7489286
    Jun 6, 2017 at 7:09
  • The four options you mention are available in database Search, but it's not what I suggested. You have to open your table. Jun 6, 2017 at 13:23
0

Without any doubt I would use http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

This tool is especially designed for the situation you describe.

You upload the code to your server and then enter the "find" and "replace"

You can then do a dry run and the system will show you all the replaces that will be made across every single table in your Wordpress database.

Once you're happy then you can do a live run and the changes are made.

I have used this on probably one hundred Wordpress sites and it works a charm.

1
  • Dear Chris, thank you very much for your answer. I always feel a bit cautious with regards to code I am not aware of, but as I mentioned for the response above, I am really tired of manually replacing them one by one so, I will also look into your option, so thank you so much once again for putting it forward and taking the time to help me out.
    – user7489286
    Jun 6, 2017 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy