天天看點

mysqldump資料導出問題和用戶端授權後連接配接失敗問題

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端口。

如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<code>mysql&gt; </code><code>select</code> <code>host,user,password from mysql.user;</code>

<code>+--------------+-----------------+----------------------------------------------------------+</code>

<code>| host              | user                 | password                                       |</code>

<code>| localhost    | root                 |                                                     |</code>

<code>| fdm1         | root                 |                                                     |</code>

<code>| 127.0.0.1    | root                 |                                                     |</code>

<code>| localhost    |                      |                                                     |</code>

<code>| fdm1         |                      |                                                     |</code>

<code>| 192.168.1.%  | db_hqsb              | *DFC9DC16B13651A95ECEC3A26E07D244431B55C9           |</code>

<code>| 192.168.1.%  | db_ro_hqsb           | *2C0B0DD50595BB40879110437BEEF026D019DFB7           |</code>

<code>| 192.168.1.%  | db_jkhwuser          | *2C0B0DD50595BB40879110437BEEF026D019DFB7           |</code>

<code>| 192.168.1.25 | slave                | *EE52B8EACB3CCD13624273AD6B5CDA52B9B53EB7           |</code>

<code>| 192.168.1.%  | tech_db_user         | *6053E57C7B61043DC2C6B4E3291D5F61CCC23F5C           |</code>

<code>| 192.168.1.%  | game_db_user         | *05EA4D71C9A1273ECF3E24E6323F7175AE45C366           |</code>

<code>| localhost    | zabbix               | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9           |</code>

<code>+---------------+---------------+-----------------------------------------------------------+</code>

問題:

在客戶機(比如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&gt; delete from mysql.user where host="localhost" and user="";

Query OK, 1 row affected (0.00 sec)

mysql&gt; 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&gt;

***************當你發現自己的才華撐不起野心時,就請安靜下來學習吧***************

本文轉自散盡浮華部落格園部落格,原文連結:http://www.cnblogs.com/kevingrace/p/5762314.html,如需轉載請自行聯系原作者