Contents
Is there a way to duplicate a database in MySQL?
With that in mind, here is a simple way to duplicate a database from the command line of a windows server: Create the target database using MySQLAdmin or your preferred method. In this example, db2 is the target database, where the source database db1 will be copied.
Is it possible to copy data from one database to another in MySQL?
You could write a script that takes the output from SHOW TABLES from one database and copies the schema to another. You should be able to reference schema+table names like: As far as the data goes, you can also do it in MySQL, but it’s not necessarily fast. After you’ve created the references, you can run the following to copy the data:
Is it possible to clone a database using MySQL?
Because uploading of mysqldumps is ugly slow if DB is over 2Gb. And you can’t clone InnoDB tables just by copying DB files (like snapshot backuping).
How to create a target database in MySQL?
Create the target database using MySQLAdmin or your preferred method. In this example, db2 is the target database, where the source database db1 will be copied. mysqldump -h [server] -u [user] -p [password] db1 | mysql -h [server] -u [user] -p [password] db2
How to dump all table structures in MySQL?
If you want to dump all tables from all databases and with no data (only database and table structures) you may use: mysqldump -P port -h hostname_or_ip -u username -p –no-data –all-databases > db_backup.sql This will produce a.sql file that you can load onto a mysql server to create a fresh database.
Is it possible to copy table files in MySQL?
If you’re using MyISAM, you’re better off to copy the table files; it’ll be much faster. You should be able to do the same if you’re using INNODB with per table table spaces. If you do end up doing an INSERT INTO SELECT, be sure to temporarily turn off indexes with ALTER TABLE x DISABLE KEYS!