Make copy of Database

If I want to make an exact copy of a MySQL database from one place to another, can I just export all the tables (in sql format), save to my local machine, create a new databae on a different place & just import all the content from the exported file (or files)?
Richard KortsAsked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
Yes, I do it all the time for backups.  Note that if this is for an active site, your copy may be out of date by the time you upload it on the second server.
0
 
Jim RiddlesPrepress/OMS SpecialistCommented:
Not sure which version of MySQL you are using, but see the following link for a full explanation: https://dev.mysql.com/doc/refman/5.7/en/mysqldump-copying-database.html.

Log on to your MySQL shell from the command line and execute the following commands:
mysqldump db1 > dump.sql
mysqladmin create db2
mysql db2 < dump.sql

Open in new window


Substitute "db1" and "db2" with whatever names are appropriate.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.