Mysql database copy, mysql database

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.