0

I have a database backup and entire site folder backup of a wordpress site. I want to setup it in my localhost. These are the steps I followed.

  1. Create a database
  2. Import the database_backup.sql
  3. Open the wp-config.php and edit the following details

define( 'DB_NAME', 'contents_wp' );

define( 'DB_USER', 'root' );

define( 'DB_PASSWORD', '' );

define( 'DB_HOST', '127.0.0.1' );

But I cannot log in to the admin panel. It redirects to the live site. How to solve this? What I am doing wrong here?

Any suggestions will be appreciated.

2 Answers 2

1

Before import database_backup.sql. You have to replace server url with your local url in sql. for example: you took backup from abc.com , and your local url is localhost/abc .then open database_backup.sql and find and replace abc.com with localhost/abc. Save and import now.

2
  • in some cases, let's say there were plugins or themes, that saved the url, you have to replace any occurence of the old url.
    – user9
    Commented Nov 27, 2013 at 11:05
  • Another option to answer above. We use VMware here (but all virtualisation software can do such!) with XP as OS, Wamp installed and pointed windows Hosts file to our domain. So you can have a 100% copy(1 on 1) of Wordpress without any change needed. Easy, fast and in emergency cases moving back to live server is peace of cake.
    – Charles
    Commented Nov 27, 2013 at 17:25
0

I prefer the approach of Charles as that is a lot easier, safer and useful approach. Still you can follow as mentioned by Saifur.

I will suggest one point here i.e. not to replace the data directly in the sql file. This is because wordpress stores data in terms of serialized manner. So even though you replace the data correctly, it may not work 100%.

In this case you first create the database and import the sql file. Then use a script to make a search and replace directly in the database. One such useful script is this one http://interconnectit.com/products/search-and-replace-for-wordpress-databases/ I have used this many times and it has always worked.

2
  • Just as addition, the reason for simply replacing data in serialized form leading to problems is that serialized data saves string length with it, so if you replace strings the length most likely will differ. The search-and-replace-tool takes this into account and saves the new string length. Commented Nov 27, 2013 at 20:10
  • @Chittaranjan, thnx for that link, needed such for a forum!
    – Charles
    Commented Nov 27, 2013 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.