bensangeorge.com

dumping mysql and importing mysql

with one comment

One thing that a developer has to do during the course of a project is to export a mysql database so that he can set up a new development environment, transfer data, etc.

In mysql, the mysqldump command works great for this:
mysqldump –verbose -user -h [hostname] -p[password] [database_name] > file.sql

When importing a sql file, just go the other way:

mysql -u [username] –verbose -p[password] -h [hostname] [database_name] < file.sql

This two commands will make importing and exporting databases a snap.

Written by bensan

March 30th, 2009 at 2:13 pm

One Response to 'dumping mysql and importing mysql'

Subscribe to comments with RSS or TrackBack to 'dumping mysql and importing mysql'.

  1. I would also add the –add-drop-table option to your mysqldump command, to make it more portable, and -c to use complete inserts, in case you want to munge the data later.

    You never know when or where your sql file will come in handly later.

    Eric Marden

    4 Aug 09 at 7:14 am

Leave a Reply