前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >mysqldump数据导出问题和客户端授权后连接失败问题

mysqldump数据导出问题和客户端授权后连接失败问题

作者头像
洗尽了浮华
发布2018-01-22 16:22:18
2.6K0
发布2018-01-22 16:22:18
举报
文章被收录于专栏:散尽浮华散尽浮华

1,使用mysqldump时报错(1064),这个是因为mysqldump版本太低与当前数据库版本不一致导致的。 mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1': You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_QUOTE_SHOW_CREATE=1' at line 1 (1064)

[root@bastion-IDC ~]# mysqldump --version mysqldump Ver 10.13 Distrib 5.1.61, for redhat-linux-gnu (x86_64)

[root@bastion-IDC ~]# mysql           //或者登陆mysql,select version();也可查看版本 Server version: 5.6.25-log Source distribution .........

这样的话必须知道mysqldump的绝对路径,在mysql的安装目录下有。

2,导出时指定字符集,报错 Character set 'utf-8' is not a compiled character set and is not specifie . --default-character-set=utf-8

这个是因为字符集错了。是--default-character-set=utf8

3,导出时提示warning,A partial dump from a server that has GTIDs [root@bastion-IDC ~]# mysqldump -uroot -p xqsj_db > xqsj_db20160811.sql Warning: A partial dump from a server that has GTIDs will by default include the GTIDs of all transactions, even those that changed suppressed parts of the database. If you don't want to restore GTIDs, pass --set-gtid-purged=OFF. To make a complete dump, pass --all-databases --triggers --routines --events.

关于GTID是5.6以后,加入了全局事务 ID (GTID) 来强化数据库的主备一致性,故障恢复,以及容错能力。 官方给的:A global transaction identifier (GTID) is a unique identifier created and associated with each transaction committed on the server of origin (master). 所以可能是因为在一个数据库里面唯一,但是当导入其他的库就有可能重复。所有会有一个提醒。

可以通过添加--set-gtid-purged=off 或者–gtid-mode=OFF这两个参数设置。 很有肯能是在导入库中重新生产GTID,而不用原来的。

[root@bastion-IDC ~]# mysqldump -uroot --set-gtid-purged=off -p xqsj_db > xqsj_db20160811.sql                      #这样就ok了!

---------------------------------------------------------------------------------------------------------

在本地(192.168.1.152)部署好mysql环境,授权远程客户机192.168.1.%连接本机的mysql,在iptables防火墙也已开通3306端口。 如下:

代码语言:javascript
复制
mysql> select host,user,password from mysql.user;
+--------------+-----------------+----------------------------------------------------------+
| host              | user                 | password                                       |
+--------------+-----------------+----------------------------------------------------------+
| localhost    | root                 |                                                     |
| fdm1         | root                 |                                                     |
| 127.0.0.1    | root                 |                                                     |
| localhost    |                      |                                                     |
| fdm1         |                      |                                                     |
| 192.168.1.%  | db_hqsb              | *DFC9DC16B13651A95ECEC3A26E07D244431B55C9           |
| 192.168.1.%  | db_ro_hqsb           | *2C0B0DD50595BB40879110437BEEF026D019DFB7           |
| 192.168.1.%  | db_jkhwuser          | *2C0B0DD50595BB40879110437BEEF026D019DFB7           |
| 192.168.1.25 | slave                | *EE52B8EACB3CCD13624273AD6B5CDA52B9B53EB7           |
| 192.168.1.%  | tech_db_user         | *6053E57C7B61043DC2C6B4E3291D5F61CCC23F5C           |
| 192.168.1.%  | game_db_user         | *05EA4D71C9A1273ECF3E24E6323F7175AE45C366           | 
| localhost    | zabbix               | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9           |
+---------------+---------------+-----------------------------------------------------------+

问题: 在客户机(比如192.168.1.20)上远程连接上面192.168.1.152机器的mysql,连接失败! [root@huanqiu ~]# mysql -udb_ro_hqsb -h 192.168.1.152 -pmhxzkhl0802xqsjdb ERROR 1130 (HY000): Host '192.168.1.20' is not allowed to connect to this MySQL server

解决: 是由于192.168.1.152的mysql里“host为localhost,user和password为空”这条语句导致的,删除这条即可解决问题!

mysql> delete from mysql.user where host="localhost" and user=""; Query OK, 1 row affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)

这样,授权连接的客户机就能成功连接了! [root@huanqiu ~]# mysql -uxqsj_db_ro_user -h 192.168.1.152 -pmhxzkhl0802xqsjdb Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 28 Server version: 5.1.73 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>

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-08-11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档