Replace Live Site Url with Local Site URL in wordpress database

Updated at 11-Nov-2022, By samar

Replace Live Site Url with Local Site URL in wordpress database

In this session, we are going to try to solve the "Replace Live Site Url with Local Site URL in wordpress database" puzzle by using the computer language.

You can use SQL query to update the Live site URL with your Local site URL. You have to simply run the query to update the value or you can also update it manually by using phpmyadmin.

  • Replace Site URL using SQL query in wordpress

    UPDATE wp_options SET option_value = replace(option_value, 'http://www.yoursitename.com', 'http://localhost/projectname') WHERE option_name = 'home' OR option_name = 'siteurl';
    UPDATE wp_posts SET post_content = replace(post_content, 'http://www.yoursitename.com', 'http://localhost/projectname');
    UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.yoursitename.com','http://localhost/projectname');
    

    First, Login in to your database via phpMyAdmin and choose database. After that, you have to click on SQL tab and paste the above code in it and hit go button to update the URL.

  • Manually update site URL of WordPress database

    Follow below step to update the site URL manually in wordpress database.

    1. Log into the database via phpMyAdmin ( cPanel / Plesk / Web Hosting / Managed WordPress ).
    2. Choose your database on which you are working on.
    3. Select table name wp_options.
    4. Now update the value of option_value column (Generally it exists at first two row), Which contain value like (https://yourdomain.com). Now you have to update all these value with new values as per your requirement (eg: http://localhost/yourwordpress-project).

Back to code snippet queries related wordpress