MySQL backup database method: First enter the bin directory under the MySQL server installation directory in the command line window; then execute [mysqldump -h host name -P port -u user name -p password –database database name> ; File name.sql] backup command is enough.
#This article will introduce how to backup MySQL database under win7 system.
Recommended courses: MySQL Tutorial.
If you want to back up the database, you must first enter the bin directory under the MySQL server installation directory in the command line window and execute the backup command.
Backup command mysqldump format
Format: mysqldump -h host name -P port -u user name -p password –database database name > ; File name.sql
The backup MySQL database is in the format with deleted tables
The backup MySQL database is in the format with deleted tables, which allows the backup to overwrite the existing database without manually deleting the original There is a database.
mysqldump --add-drop-table -uusername -ppassword -database databasename > backupfile.sql
Directly compress the backup of the MySQL database
mysqldump -hhostname -uusername - ppassword -database databasename | gzip > backupfile.sql.gz
Backup a certain table(s) of the MySQL database
mysqldump -hhostname -uusername -ppassword databasename specific_table1 specific_table2 > backupfile.sql
Back up multiple MySQL databases at the same time
mysqldump -hhostname -uusername -ppassword –databases databasename1 databasename2 databasename3 > multibackupfile.sql only backs up 6, only backs up the database structure
mysqldump –no-data –databases databasename1 databasename2 databasename3 > structurebackupfile.sql
Backup all databases on the server
mysqldump –all-databases > allbackupfile.sql
Note: If Execute the backup command in the bin directory under the MySQL server installation directory, and the backed up sql files will also be in the bin directory under the MySQL server installation directory.
The above is the detailed content of How to backup MySQL database. For more information, please follow other related articles on the PHP Chinese website!