9

mysql 备份数据库,并且在别的服务器上恢复

 3 years ago
source link: https://blog.popkx.com/mysql-backup-database-and-restore-on-other-server/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

mysql 备份数据库,并且在别的服务器上恢复

发表于 2018-07-29 22:07:52   |   已被 访问: 252 次   |   分类于:   杂谈   |   暂无评论

第一反应是以下命令

sudo mysqldump -hxx -uxx -ppass database> /var/lcc_proxies.sql

但是失败了,错误信息如下图

百度之,发现备份对目录也有要求,mysqldump 是用系统帐号执行的。而select .. outfile ..是mysql帐号执行的。
修改权限或则 把/var 路径改为 改成/tmp 就没问题了。

sudo mysqldump -hxx -uxx -ppass database> /tmp/lcc_proxies.sql



恢复就简单了。以下是一个实例,我将 lcc_proxies.sql 拷贝到 win7 桌面。进入数据库后,执行以下命令:

create database lcc_proxies;
use lcc_proxies;
source C:\Users\Administrator\Desktop\lcc_proxies.sql;

这样就成功了,执行以下查询命令,可以看到结果如下图所示:

show tables;
show columns from lcc_proxies;

阅读更多:   杂谈


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK