MySQL Data backup and recovery

Source: Internet
Author: User

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

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.