Overview

Copying your existing MySQL database is quite a simple task, in fact you can do it in a single command! There are plenty of times when you want to take a copy of an existing database so that you leave your original database untouched. For example, if you want to run different databases for your production and development environments then you can copy the existing database to test making changes. 

Note: This assumes that you're copying the database onto the same server.

Instructions

  1. Run the "mysqldump" program and pipe it directly back into "mysql":
    mysqldump --user=<username> --password=<password> <existingdatabase> | mysql --user=<username> --password=<password> <newdatabasename>
  2. That's it!

Was this article helpful?

Related Articles