MySQL Database copy

Source: Internet
Author: User
Tags mysql command line
We often have the need to copy the MySQL database on a server to another machine, such as a database migration.    The simplest way to do this is to use the off-the-shelf tools provided by MySQL: Mysqldump.    When using mysqldump, you need to specify the account, password, host and other information. For example: Mysqldump-h 10.10.8.12-u backup-p 6071-p backup_db >backup_db.mysql above command to save 10.10.8.12 host's backup_db database in Backu The P_db.mysql file. -u backup indicates the user name,-p 6071 for the port,-p for the password, here we use the command line input, so here the password is blank. BACKUP_DB is the name of the database we want to replicate. After executing this command we will get the Backup_db.mysql file, which is actually the redirect to the mysqldump output file. This file holds the MySQL statements needed to replicate the database. We then copy this file to the target machine we want to copy to, then go to the MySQL command line, enter a database, and then execute the source backup_db.mysql to complete the database replication.    After the execution you will find that the process of copying a database is to execute a number of SQL statements, mysqldump to do is to the contents of the database in the form of SQL statements exported. It is also important to note that you may encounter the following problem when Mysqldump: Mysqldump:got error:1044:access denied for user ' backup ' @ ' 10.10.4.42 ' to Databas E ' backup ' when using LOCK TABLES This problem is caused by mysqldump attempting to lock the entire table. Just add the--skip-lock-tables option to solve the above problem.
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.