1130 Host '192.168.241.128' is not allowed to connect to this MySql server
参考:https://blog.csdn.net/h996666/article/details/80917268
# /mysql/bin/mysql -uroot -proot_123 -S /mysql/data/mysql.sock //登陆mysql mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 Server version: 8.0.21 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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>
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) mysql> use mysql //进入mysql数据库 Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> mysql> update user set host='%' where user ='root'; //更新域属性,'%'标识允许外部访问 Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> FLUSH PRIVILEGES; //刷新 Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION; //授权 Query OK, 0 rows affected (0.00 sec)
FLUSH PRIVILEGES; 命令本质上的作用是:
将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里。
MySQL用户数据和权限有修改后,希望在"不重启MySQL服务"的情况下直接生效,那么就需要执行这个命令。
通常是在修改ROOT帐号的设置后,怕重启后无法再登录进来,那么直接flush之后就可以看权限设置是否生效。
而不必冒太大风险。