ERROR 1130 (HY000): Host 'db01' is not allowed to connect to this MySQL server
原因: mysql.user表里没有此用户root@192.168.1.23信息,重新创建用户root@192.168.1.23或root@192.168.1.%即可
[root@db01 ~]# mysql -uroot -p -h 192.168.1.23
Enter password:
ERROR 1130 (HY000): Host 'db01' is not allowed to connect to this MySQL server
[root@db01 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> select user,host from mysql.user;
+---------------+-----------+
| user | host |
+---------------+-----------+
| root | 127.0.0.1 |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-----------+
4 rows in set (0.00 sec)
mysql> create user root@'192.168.1.%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to root@'192.168.1.%';
Query OK, 0 rows affected (0.00 sec)
[root@db01 ~]# mysql -uroot -p -h 192.168.1.23
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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> show processlist;
+----+------+------------+------+---------+------+----------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+------------+------+---------+------+----------+------------------+
| 7 | root | db01:34188 | NULL | Query | 0 | starting | show processlist |
+----+------+------------+------+---------+------+----------+------------------+
1 row in set (0.00 sec)
mysql> select user,host from mysql.user;
+---------------+-------------+
| user | host |
+---------------+-------------+
| root | 127.0.0.1 |
| root | 192.168.1.% |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+---------------+-------------+
5 rows in set (0.01 sec)