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