Mysql tutorial quick database tutorial backup and automatic backup bat processing method, the first example below is the bat batch processing method, followed by commonly used SQL data backup commands.
@ Echo off
Echo.
Echo MySQL Database Backup
Echo *****************************
Echo.
Echo today is % date %
Echo time is % time %
Echo.
Echo *****************************
Set "Ymd = % date :~, 4% % date :~ 5, 2% % date :~ 8, 2%"
Md "D: % Ymd %"
"C: Program FilesMySQLMySQL Server 5.1 binmysqldump" -- opt-Q-uroot-proot -- default-character-set = gbk mysql> "D: % Ymd % mySQLteble. SQL"
Echo.
Echo MySQL database backup is complete. Please check...
Echo.
Echo.
Pause
The above is the bat backup method,
Command for backing up MySQL database
Mysqldump-hhostname-uusername-ppassword databasename> backupfile. SQL
Back up the MySQL database in the format of a table with deletion
Backing up a MySQL database is in the format of a table with deletion, so that the backup can overwrite existing databases without the need to manually delete the original database.
Mysqldump -- add-drop-table-uusername-ppassword databasename> backupfile. SQL
Directly compress and back up the MySQL database
Mysqldump-hhostname-uusername-ppassword databasename | gzip> backupfile. SQL .gz
Back up a MySQL database table
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
Back up database structures only
Mysqldump-no-data-databases databasename1 databasename2 databasename3> structurebackupfile. SQL
Back up all databases on the server
Mysqldump-all-databases> allbackupfile. SQL
Command for restoring MySQL database
Mysql-hhostname-uusername-ppassword databasename <backupfile. SQL
Restore a compressed MySQL database
Gunzip <backupfile. SQL .gz | mysql-uusername-ppassword databasename
Transfer database to new server
Mysqldump-uusername-ppassword databasename | mysql-host = *. *-C databasename