As we continue our tutorial series on migrating your WordPress site to Inmotion hosting, the next thing we want to cover is how to update the URLS for images within your pages and posts. They are coded differently so simply changing the site URL will not fix this. In this tutorial we show you how to fix this by using your phpMyAdmin tool.

IMPORTANT! Note that this step is not mandatory. It is only necessary if your domain name is changing during the migration.

Correcting image links after a migration

  1. Log into your cPanel interface.
  2. select phpmyadmin toolOnce inside the cPanel, find the Databases category and click on the phpMyAdmin tool icon.
  3. select new databaseYou are now on the main phpMyAdmin page. Find the newly added database and click on its name from the left-hand sidebar. Our sample database is named testdb.
  4. select database tableThis opens the database and the screen refreshes with a list of the tables. Using the sidebar again, find and click on the wp-posts table.
  5. click the SQL buttonLook to the top of the screen and you will see several tabs that run across the page. Click on the SQL tab.
  6. enter the SQL code and run it

    You are now on a MySQL editor screen. In the code area, copy the following bit of MySQL.

    UPDATE wp_posts SET post_content=(REPLACE (post_content, '<old url>','<new url>'));

    Be sure to replace <old_url> with the old sitename and <new_url> with the new site name. For instance, our original site was and the new test site will be at so the code should appear as below:

    UPDATE wp_posts SET post_content=(REPLACE (post_content, '',''));

    Click on the Go button to run the code and change the URLs for all images in the posts. This will also affect any other 'hard coded' links that were in the posts that pointed to the original site.

    Below are before and after shots of the changes made. Note that the image paths are displayed in the lower left hand corners of the images. You can see how they switched to the new sitename after the SQL code ran.

    before the link changeafter the link change
You are viewing Section 5: Correcting image links after a WordPress migration
Section 4: Configuring WordPress After a Migration
Section 6: Testing your WordPress website after Migration
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Support Center Login

Social Media Login

Related Questions

Here are a few questions related to this article that our customers have asked:
How do I fix image links after domain change?
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-09-13 3:04 pm

I followed the instructions concerning image links after migration,  however the images are still not being loaded when viewed in browsers. Can you offer any other instructions to assist?

23,972 Points
2014-09-15 8:19 am
Hello Rexford,

Right click on one of the missing images and get the image information from the menu there. This will include the URL where the program is looking for the image. Check to see that it is correct. If not, then run through the above again to change the URL. If it is still occurring we may need to take a look at files your account if you are one of our customers to see where the settings are incorrect.

Kindest Regards,
Scott M
n/a Points
2014-10-11 3:59 pm

After hours of hours searching I can finally proceed.sign...that feeling. thanks alot Sir! 

n/a Points
2014-10-12 10:13 am

Thanks for the tip but that only changes the image link and not the URL the image is linked to which can be either an attachment, image or custom URL.

23,972 Points
2014-10-12 4:39 pm
Hello Sam,

As a general replace query, it will replace all URLs of the set type to the new one, but specifically in the post_content column on the wp_poststable. If you need to replace URLs in other columns or tables, you would use the same type of query, but for that particular table/column combination.

Kindest Regards,
Scott M
n/a Points
2014-11-02 7:59 am

Hi, thank you for your article. thats really helpfull for me. I just updated mine 1000+ images links. Wishing you very best of luck for your business.

n/a Points
2014-12-18 3:52 am

Good day, i tried it but i keep getting this      #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE wp_posts SET post_content=(REPLACE (post_content, 'localhost:81/impgaller' at line 2  

    the images are linked to my local host because i built it locally now its online and i cant change the links. Help

23,972 Points
2014-12-18 8:58 am
Hello Steevy,

Thanks for contacting us about your error. Does the error message give the complete query? The replace statement appears to be incomplete and would give that type of error if run in that fashion. Be sure it has a second parameter with the new location for the images and closes out with double parentheses, like )).

Kindest Regards,
Scott M
n/a Points
2015-01-23 11:00 am
Perfect... being careful and following step by step as shown will work!

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

9 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!