Refreshing the database on a development environment

If you have a live site which is constantly updated and a local environment once in a while an update to the local database is required.

Phpmyadmin allows you to export the database from the live site, but if the dump file is a large one, phpmyadmin has trouble importing it (size limits and script timeouts).

The easy way to do this is to use phpmyadmin to drop all the tables of the database on the development server and then use a command line mysql command for the import:

In my case I used:

2 comments

  1. if you receive a “Duplicate entry error” the fix is to export the db in Phpmyadmin with the “Add DROP TABLE statement” option checked

  2. to make sure we are importing with the right encoding use:
    –default_character_set utf8
    e.g.:
    mysql -u root -p –default_character_set utf8 wordpress_db < wordpress_dump.sql

Leave a Reply

Your email address will not be published. Required fields are marked *