MySQL Replication database
To make it easy to copy a database quickly, you can use the following command
Copy the data from the DB1 database and the table structure to the NEWDB database
Create a new database
#mysql -u root -p123456mysql>CREATE DATABASE `newdb` DEFAULT CHARACTER SET UTF8 COLLATE UTF8_GENERAL_CI;
Copy database, use mysqldump and MySQL command combination to complete replication at once
#mysqldump db1 -u root -p123456 --add-drop-table | mysql newdb -u root -p123456
Note the-p123456 parameter:-P followed by the password directly, no space in the middle)
The above is the method of replicating the database on the same MySQL server. If you are copying to a remote other MySQL server, you can use the "-H hostname/IP" parameter of MySQL. The premise is that MySQL allows remote connections, and the transfer efficiency and time of remote replication are acceptable.
Not on the same MySQL server
#mysqldump db1 -uroot -p123456 --add-drop-table | mysql -h 192.168.1.22 newdb -u root -p123456
MySQL Replication database