| unauthenticated user (1130, "Host '127.0.0.1' is not allowed to connect to this MySQL server")

mysql> show processlist;
+----+----------------------+-----------------+------+---------+------+------------------------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+----------------------+-----------------+------+---------+------+------------------------+------------------+
| 4 | event_scheduler | localhost | NULL | Daemon | 1532 | Waiting on empty queue | NULL |
| 10 | root | localhost | NULL | Query | 0 | starting | show processlist |
| 38 | unauthenticated user | connecting host | NULL | Sleep | 29 | login | PLUGIN |
+----+----------------------+-----------------+------+---------+------+------------------------+------------------+
3 rows in set (0.00 sec)

解决MySQL出现大量unauthenticated user的问题 - phphot - CSDN博客 https://blog.csdn.net/phphot/article/details/4134913

MySQL Bugs: #6070: "unauthenticated user" "reading from net" process hangs https://bugs.mysql.com/bug.php?id=6070

mysql> show global variables like "%name%";
+-----------------------------------+---------------------------------+
| Variable_name | Value |
+-----------------------------------+---------------------------------+
| hostname | d |
| innodb_buffer_pool_filename | ib_buffer_pool |
| lc_time_names | en_US |
| log_bin_basename | /data/mysql/datadir/binlog |
| lower_case_table_names | 0 |
| relay_log_basename | /data/mysql/datadir/d-relay-bin |
| skip_name_resolve | OFF |
| validate_password.check_user_name | ON |
+-----------------------------------+---------------------------------+
8 rows in set (0.00 sec)

mysql>

通过命令行修改 失败

mysql> set global skip_name_resolve=1;
ERROR 1238 (HY000): Variable 'skip_name_resolve' is a read only variable
mysql>

修改

my.cnf

[mysqld]添加

skip_name_resolve=1

重启mysqld

(1130, "Host '127.0.0.1' is not allowed to connect to this MySQL server")

MySQL :: MySQL 8.0 Reference Manual :: 8.12.4.2 DNS Lookup Optimization and the Host Cache https://dev.mysql.com/doc/refman/8.0/en/host-cache.html

Using the --skip-host-cache option is similar to setting the host_cache_size system variable to 0, but host_cache_size is more flexible because it can also be used to resize, enable, and disable the host cache at runtime, not just at server startup. Starting the server with --skip-host-cache does not prevent changes to the value ofhost_cache_size, but such changes have no effect and the cache is not re-enabled even if host_cache_size is set larger than 0 at runtime.

To disable DNS host name lookups, start the server with the --skip-name-resolve option. In this case, the server uses only IP addresses and not host names to match connecting hosts to rows in the MySQL grant tables. Only accounts specified in those tables using IP addresses can be used. (A client may not be able to connect if no account exists that specifies the client IP address.)


mysql> select * from user;
+-----------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+------------------------------------------------------------------------+------------------+-----------------------+-------------------+----------------+------------------+----------------+------------------------+---------------------+--------------------------+
| Host | User | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_questions | max_updates | max_connections | max_user_connections | plugin | authentication_string | password_expired | password_last_changed | password_lifetime | account_locked | Create_role_priv | Drop_role_priv | Password_reuse_history | Password_reuse_time | Password_require_current |
+-----------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+------------------------------------------------------------------------+------------------+-----------------------+-------------------+----------------+------------------+----------------+------------------------+---------------------+--------------------------+
| localhost | mysql.infoschema | Y | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | | | | | 0 | 0 | 0 | 0 | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | N | 2018-12-21 17:31:02 | NULL | Y | N | N | NULL | NULL | NULL |
| localhost | mysql.session | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | Y | N | N | N | N | N | N | N | N | N | N | N | N | N | | | | | 0 | 0 | 0 | 0 | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | N | 2018-12-21 17:31:02 | NULL | Y | N | N | NULL | NULL | NULL |
| localhost | mysql.sys | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | N | | | | | 0 | 0 | 0 | 0 | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | N | 2018-12-21 17:31:02 | NULL | Y | N | N | NULL | NULL | NULL |
| localhost | root | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | Y | | | | | 0 | 0 | 0 | 0 | mysql_native_password | *5180F4AB915BCBB8DFF27EB412C82E08E898CF18 | N | 2018-12-24 17:18:18 | NULL | N | Y | Y | NULL | NULL | NULL |
+-----------+------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+-----------------------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+---------------+-------------+-----------------+----------------------+-----------------------+------------------------------------------------------------------------+------------------+-----------------------+-------------------+----------------+------------------+----------------+------------------------+---------------------+--------------------------+
4 rows in set (0.00 sec)

原文地址:https://www.cnblogs.com/rsapaper/p/10167553.html