Mysql database copy, mysql database
We often have this requirement to copy the mysql database on a server to another machine, such as database migration. To do this, use the ready-made mysql tool mysqldump. When using mysqldump, you must specify the account, password, host, and other information. For example, run the mysqldump-h 10.10.8.12-u backup-P 6071-p backup_db> backup_db.mysql command to save the backup_db database of the 10.10.8.12 host to the backup_db.mysql file. -U backup indicates the user name,-P 6071 indicates the port, and-p indicates the password. Here we use command line input, so the password here is blank. Backup_db is the name of the database to be copied. After executing this command, we will get the backup_db.mysql file, which is actually the redirected file output by mysqldump. This file stores the mysql statements required to copy the database. Then we copy the file to the target machine we want to copy, and then enter the mysql command line, enter a database, and then execute source backup_db.mysql to copy the database. After execution, you will find that the process of copying a database is to execute some column SQL statements. mysqldump is to export the database content in the form of SQL statements. Note that you may encounter the following problems during mysqldump: Got error: 1044: Access denied for user 'backup '@ '10. 10.4.42 'to database' backup 'when using lock tables this problem occurs because mysqldump attempts to LOCK the entire table. You only need to add the -- skip-lock-tables option to solve the above problem.
Copy the mysql database to another computer
1. copy the data folder in the mysql directory and put it in the corresponding directory of other computers.
2. You can also import all the data into SQL statements and execute them in mysql on other computers. phpmyadmin is convenient to use here.
How to copy a MySQL database
You can directly put this folder in the mysql data DIRECTORY, And then you can see this database in the Manager. (Mysql service may need to be stopped before restarting)