Syntax: mysqldump-u user name-p password database name > backup file name
1. Backup library mysqldump-uroot-p123456 mysql >/tmp/mysql.sql
[Email protected] ~]# mysqldump-uroot-p123456 MySQL >/tmp/mysqlbak.sql
--warning:skipping The data of table mysql.event. Specify the--events option explicitly.
[Email protected] ~]# ls/tmp/
Ks-script-nndife Mysqlbak.sql Mysql.sock Yum.log
[[email protected] ~]# mysql-uroot-p1-e "CREATE Database Mysql2";//create a new library
2. Recovery library mysql-uroot-p123456 MySQL </tmp/mysql.sql
[[email protected] ~]# MYSQL-UROOT-P1 MYSQL2 </tmp/mysql.sql//recovery Library
[[email protected] ~]# mysql-uroot-p123456 MYSQL2//So you can log in directly MYSQL2
Mysql> Select Database ();
+------------+
| Database () |
+------------+
| MYSQL2 |
+------------+
1 row in Set (0.00 sec)
3. Backup table mysqldump-uroot-p123456 mysql user >/tmp/user.sql//Courin Gerzo
[[email protected] ~]# mysqldump-uroot-p123456 mysql user >/tmp/user.sql
[Email protected] ~]# ls/tmp/
Ks-script-nndife mysqlbak.sql mysql.sock User.sql yum.log
[Email protected] ~]# Less/tmp/user.sql
4. Restore table mysql-uroot-p123456 MySQL </tmp/user.sql
mysql-uroot-p123456 MYSQL2 </tmp/user.sql
5. Back up all libraries mysqldump-uroot-p-A >/tmp/123.sql
6. Back up the table structure only mysqldump-uroot-p123456-d mysql >/tmp/mysql.sql
Problem!!!
mysql> mysqldump-uroot-p1 db1 >/tmp/mysql.sql; Can not be executed in MySQL, this is an order, not add;
Error 1064 (42000): You have a error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near ' mysqldump-uroot-p1 DB1 >/tmp/mysql.sql ' at line 1
MySQL Data backup and recovery