MySQL Command Line Backup database

Source: Internet
Author: User
Tags mysql command line

MySQL database using command-line Backup | MySQL Database backup command

For example:

Database address: 127.0.0.1

Database user name: root

Database Password: Pass

Database name: MyWeb

Back up the database to the D disk and directory Mysqldump-h127.0.0.1-uroot-ppass myweb > D:/backupfile.sql

Back up to current directory The MySQL database is formatted with the Delete table, allowing the backup to overwrite the existing database without having to manually delete the existing database mysqldump--add-drop-table-h127.0.0.1-uroot-ppass myweb > Backupfile.sql

Backup the MySQL database compressed backup directly  to the D disk and directory Mysqldump-h127.0.0.1-uroot-ppass MyWeb | gzip > d:/backupfile.sql.gz

Back up some (some) tables from the MySQL database. This example backs up the Table1 table and the Table2 table. Back up to Linux host Mysqldump-h127.0.0.1-uroot-ppass myweb table1 table2 >/home/backupfile.sql

Back up multiple MySQL databases simultaneously mysqldump-h127.0.0.1-uroot-ppass--databases myweb myweb2 > Multibackupfile.sql

Simply back up the database structure. Backup is also named MyWeb database and named MYWEB2 database mysqldump--no-data-h127.0.0.1-uroot-ppass--databases myweb myweb2 > Structurebackupfile.sql

Back up all databases on the server mysqldump--all-databases-h127.0.0.1-uroot-ppass > Allbackupfile.sql

The command to restore the MySQL database. Restore the currently backed up database named Backupfile.sql Mysql-h127.0.0.1-uroot-ppass MyWeb < Backupfile.sql

Restore compressed MySQL database Gunzip < backupfile.sql.gz | Mysql-h127.0.0.1-uroot-ppass MyWeb

Transfer the database to the new server. This example copies the local database myweb to the remote database named Serweb, where the remote database must be named Serweb database Mysqldump-h127.0.0.1-uroot-ppass MyWeb | MySQL--host=***.***.***.***-u database user name-p database password-c serweb

MySQL Command Line Backup database

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.