1. 1.备份库
    2. [root@bai ~]# mysqldump -uroot -pbai123 mysql > /tmp/mysql.sql;
    3. Warning: Using a password on the command line interface can be insecure.
    4. 2.恢复库
    5. [root@bai ~]# mysql -uroot -pbai123 mysql</tmp/mysql.sql
    6. Warning: Using a password on the command line interface can be insecure.
    7. 3.备份表
    8. [root@bai ~]# mysqldump -uroot -pbai123 mysql user> /tmp/user.sql;
    9. Warning: Using a password on the command line interface can be insecure.
    10. 4.恢复表
    11. [root@bai ~]# mysql -uroot -pbai123 mysql > /tmp/user.sql;
    12. Warning: Using a password on the command line interface can be insecure.
    13. //查看备份表的内容
    14. # less /tmp/user.sql

    图:
    image.png

    1. 5.备份所有库(一个一个备份很麻烦,所以用这条命令)
    2. [root@bai ~]# mysqldump -uroot -pbai123 -A >/tmp/123.sql
    3. Warning: Using a password on the command line interface can be insecure.
    4. 6.只备份表结构
    5. [root@bai ~]# mysqldump -uroot -pbai123 -d mysql > /tmp/mysql.sql
    6. Warning: Using a password on the command line interface can be insecure.
    7. [root@bai ~]#

    image.png