ERROR 1130 (HY000): Host '' is not allowed to connect to this MySQL server [duplicate] Ask Question

ERROR 1130 (HY000): Host '' is not allowed to connect to this MySQL server [duplicate] Ask Question

Why oh why can I not connect to mysql?

mysql -u root -ptest101 -h xxx.xxx.xxx.xxx
ERROR 1130 (HY000): Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server

In my.cnf I have the below

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address        = 0.0.0.0

I also ran the below...

'UPDATE mysql.user SET Password = PASSWORD('test101') WHERE User = 'root';
FLUSH PRIVILEGES;

I can access on the host machine using mysql -u root -ptest101 but not using mysql -u root -ptest101 -h xxx.xxx.xxx.xxx

Wow...why is this happening? I am n ubuntj 12.04

mysql> SELECT host FROM mysql.user WHERE User = 'root';
+---------------------------------------------+
| host                                        |
+---------------------------------------------+
| %                                           |
| 127.0.0.1                                   |
| ::1                                         | |
| localhost                                   |
+---------------------------------------------+
5 rows in set (0.00 sec)

ベストアンサー1

Your root account, and this statement applies to any account, may only have been added with localhost access (which is recommended).

You can check this with:

SELECT host FROM mysql.user WHERE User = 'root';

localhostとのみの​​結果が表示される場合127.0.0.1、外部ソースから接続することはできません。他の IP アドレスは表示されるが、接続元の IP アドレスが表示されない場合も、外部ソースから接続できないことを示しています。

アクセスを許可する各システムの IP アドレスを追加し、権限を付与する必要があります。

CREATE USER 'root'@'ip_address' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address';

が表示された場合%、それは「任意のリモート ソース」であるため、まったく別の問題があります。ただし、任意の/すべてのシステムをルート経由で接続したい場合は、ワイルドカードを使用して%アクセスを許可します。

CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';

最後に、権限を再読み込みすると、リモート アクセスが可能になります。

FLUSH PRIVILEGES;

おすすめ記事