Duplicate MySQL database from command line

  1. Create the target database using MySQLAdmin or your preferred method. In this example, my_database_copy is the target database, where the source database my_database will be copied.
  2. Execute the following statement on a command line:

mysqldump -h [server] -u [user] -p[password] my_database | mysql -h [server] -u [user] -p[password] my_database_copy

Note: There is NO space between -p and [password]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s