设为首页 收藏本站
查看: 714|回复: 0

[经验分享] MySQL 5.5 mysqldump工作过程中遇到的问题

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-3-2 08:51:19 | 显示全部楼层 |阅读模式
                      场景1:

1
2
3
4
系统版本:CentOS 6.4
MySQL版本:5.5.35-log Source distribution
逻辑备份命令:mysqldump
还原数据命令:source



条件:

1
2
3
备份文件
[iyunv@localhost ~]# ll -d /tmp/cloudTest.sql
-rw-r--r-- 1 root root 1575809806 2月  28 09:04 /tmp/cloudTest.sql




问题:备份文件cloudTest,sql是二进制安装MySQL5.5下的备份文件,然后导入到源码编译MySQL5.5环境下中遇到的导入错误,重复导入几次,依然报错如下:
恢复现场:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
[iyunv@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.5.35-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> create database cloudTest;
mysql> user cloudTest;
mysql> set session sql_log_bin = 0
mysql> source /tmp/cloudTest.sql;

......(执行时长25分钟左右)
ERROR 1231 (42000): Variable 'time_zone' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'sql_mode' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'foreign_key_checks' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'unique_checks' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'character_set_client' can't be set to the value of 'NULL'
Query OK, 0 rows affected (0.00 sec)

ERROR 1231 (42000): Variable 'collation_connection' can't be set to the value of 'NULL'
ERROR 1231 (42000): Variable 'sql_notes' can't be set to the value of 'NULL'



解决办法:

1
2
3
4
5
6
7
[iyunv@localhost ~]# vim /etc/my.cnf
[mysqld]
max_allowed_packet = 500M

[mysqldump]
quick
max_allowed_packet = 500M



1
[iyunv@localhost ~]# service mysqld restart



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
再次执行恢复现场操作
[iyunv@localhost ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.5.35-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> create database cloudTest;
mysql> user cloudTest;
mysql> set session sql_log_bin = 0
mysql> source /tmp/cloudTest.sql;



QQ截图20150302085101.png 解释参数的含义:
max_allowed_packet
1
缓冲区的最大大小为客户端/服务器通信。默认为24MB,最大1GB。



net_buffer_length
1
该缓冲区的初始大小的客户端/服务器通信。创建多行插入语句时(与延伸————插入或选择选项),mysqldump创建行了net_buffer_length长度。如果你增加这个变量,你还应该确保在MySQL服务器变量至少大net_buffer_length。






场景2:

问题:在使用mysqldump对mysql进行数据库备份的时候,发现某些库不能直接备份;比如
1
2
3
[iyunv@localhost script]# mysqldump -uroot -p performance_schema > /tmp/performance_schema.sql
Enter password:
mysqldump: Got error: 1142: SELECT,LOCK TABL command denied to user 'root'@'localhost' for table 'cond_instances' when using LOCK TABLES



于是,今天在MySQL 5.5官网上看到了mysqldump的用法,才明白原来是这样的

wKiom1TxcE3zQ7tlAAGAGlcUyow616.jpg 解决办法:
1
--skip-lock-tables



1
2
3
4
[iyunv@localhost script]# mysqldump -uroot -p performance_schema --skip-lock-tables > /tmp/performance_schema.sql
Enter password:
[iyunv@localhost script]# ll -d /tmp/performance_schema.sql
-rw-r--r-- 1 root root 16728 2月  28 15:38 /tmp/performance_schema.sql







   

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-42876-1-1.html 上篇帖子: 在centos6.5安装MariaDB(mysql) 下篇帖子: Mysql主从不同步问题处理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表