备份sql
#导出整个数据库(包括数据库中的数据) #mysqldump -u 用户名 -p 数据库 > 备份的路径及文件名 [root@hll ~]# mysqldump -u hll -p hll > /home/hll.sql #输入密码 Enter password: [root@hll ~]# #导出数据库中的某张数据表(包含数据) #mysqldump -u 用户名 -p 数据库 表名 > 备份的路径及文件名 [root@hll ~]# mysqldump -u hll -p hll user > /home/user.sql #输入密码 Enter password: [root@hll ~]#
还原sql
#还原数据库 #mysql -u 用户名 -p -f 数据库 < 备份的路径及文件名(-f 参数表示在导出过程中忽略出现的SQL错误) [root@hll ~]# mysql -u hll -p -f hll < /home/hll.sql #输入密码 Enter password: [root@hll ~]#
文章来源: centos 备份与还原mysql