MySQL Database Backup Command

Source: Internet
Author: User
Keywords database mysql mysql database backup

MySQL is an open source relational database management system (RDBMS) that uses the most commonly used database management language-Structured Query Language (SQL) for database management.


E.g:


Database address: 127.0.0.1

Database user name: root

Database password: pass

Database name: myweb

1. Backup database to D drive and directory

mysqldump-h127.0.0.1-uroot-ppass myweb>d:/backupfile.sql

2. Back up to the current directory The backup MySQL database is in the format with deleted tables, which can make the backup overwrite the existing database without manually deleting the original database

mysqldump--add-drop-table -h127.0.0.1 -uroot -ppass myweb> backupfile.sql

3. Directly compress and backup the MySQL database to the D drive and the directory

mysqldump-h127.0.0.1-uroot-ppass myweb|gzip>d:/backupfile.sql.gz

4. Back up a certain table(s) of the MySQL database. This example backs up table1 and table2. Back up to /home on the linux host

mysqldump-h127.0.0.1-uroot-ppass myweb table1 table2>/home/backupfile.sql

5. Back up multiple MySQL databases at the same time

mysqldump-h127.0.0.1-uroot-ppass--databases myweb myweb2> multibackupfile.sql

6. Only backup the database structure. Back up the database named myweb and the database named myweb2 at the same time

mysqldump--no-data -h127.0.0.1 -uroot -ppass --databases myweb myweb2> structurebackupfile.sql

7. Back up all databases on the server

mysqldump--all-databases -h127.0.0.1 -uroot -ppass> allbackupfile.sql

8. The command to restore the MySQL database. Restore the current backup database named backupfile.sql

mysql-h127.0.0.1-uroot-ppass myweb

9. Restore the compressed MySQL database

gunzip

10. Transfer the database to the new server. This example is to copy the local database myweb to the remote database named serweb, and the remote database must have a database named serweb

mysqldump-h127.0.0.1-uroot-ppass myweb|mysql--host=***.***.***.*** -u database user name -p database password -C serweb

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.