First enter the folder you want to back up to, and then execute the following command
Back up database, SSH command: mysqldump-p database name-u database username > bak.sql (also can be the file name you want)
Do not compress backups
MYSQLDUMP-P database name-u database user name > Bak.sql
GZ Compressed Backup
MYSQLDUMP-P database name-u database User name | gzip > wuxiaowu.sql.gz
Zip Compressed backup
MYSQLDUMP-P database name-u database User name | gzip > Wuxiaowu.sql.zip
I don't have any of the following to verify that I can use
The following are the SSH commands summarized by the network for MySQL database backup and recovery:
Commands for backing up the MySQL database
Mysqldump-hhostname-uusername-ppassword databasename > Backupfile.sql
Backing up the MySQL database for a deleted table format
Backing up the MySQL database is a format with a deleted table that allows the backup to overwrite the existing database without having to manually delete the original database.
Mysqldump-–add-drop-table-uusername-ppassword databasename > Backupfile.sql
Directly compress MySQL database to backup
Mysqldump-hhostname-uusername-ppassword DatabaseName | gzip > backupfile.sql.gz
Backing up a MySQL database (some) tables
Mysqldump-hhostname-uusername-ppassword databasename specific_table1 specific_table2 > Backupfile.sql
Backup multiple MySQL databases at the same time
Mysqldump-hhostname-uusername-ppassword–databases databasename1 databasename2 databasename3 > Multibackupfile.sql
Just back up the database structure
Mysqldump–no-data–databases databasename1 databasename2 databasename3 > Structurebackupfile.sql
Back up all databases on the server
Mysqldump–all-databases > Allbackupfile.sql
command to restore MySQL database
Mysql-hhostname-uusername-ppassword DatabaseName < Backupfile.sql
Restoring a compressed MySQL database
Gunzip < backupfile.sql.gz | Mysql-uusername-ppassword DatabaseName
Transferring a database to a new server
Mysqldump-uusername-ppassword DatabaseName | Mysql–host=*.*.*.*-C DatabaseName
Several common database backup instances: 1. Export the entire database
Mysqldump-u user name-p database name > exported file name
Mysqldump-u root-p Dataname >dataname.sql
This time will prompt you to enter the root username password, enter the password after the Dataname database is successfully backed up in the current directory. 2. Export a table
Mysqldump-u user name-P database name Table name > exported file name
Mysqldump-u root-p dataname users> dataname_users.sql
3. Export a database structure
Mysqldump-u wcnc-p-d–add-drop-table SMGP_APPS_WCNC >d:/wcnc_db.sql
-D No data –add-drop-table add a drop table4 before each CREATE statement. Import Database
Common source Commands
Enter the MySQL database console,
such as Mysql-u root-p
Mysql>use Database
Then use the source command, followed by the script file (such as the. SQL used here)
Mysql>source D:/wcnc_db.sql