zoukankan      html  css  js  c++  java
  • 解决Host 'X.X.X.X' is not allowed to connect to this MySQL server

    在 CentOS7 上装了MySQL,安装成功后,修改完登录密码,然后用工具连接该服务器,报了一个错误。尝试用终端去连接 MySQL 数据库。同样报了一个错误。

    ➜  ~ mysql -h 192.168.20.163 -u root
    ERROR 1130 (HY000): Host '192.168.118.118' is not allowed to connect to this MySQL server

    这个说明了MySQL出于安全性考虑只允许本地进行命令访问。

    那就需要登录到服务器上,连接到本地数据库。

    执行以下命令。

    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)
    
    mysql> use 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> update user set host = '%' where user = 'root';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select host,user from user;
    +-----------+-----------+
    | host      | user      |
    +-----------+-----------+
    | %         | root      |
    | localhost | mysql.sys |
    +-----------+-----------+
    2 rows in set (0.00 sec)

    再次使用工具连接MySQL数据库,就可以了。

  • 相关阅读:
    立体图
    旅行家的预算
    洛谷P多米诺骨牌
    洛谷P2331最大子矩阵
    理想的正方形
    2015 ACM/ICPC Asia Regional Hefei Online Find a path
    Atcoder abc 138 F
    Atcoder abc 138 E String of Impurity
    zlb的8.19考试
    Atcoder abc 138
  • 原文地址:https://www.cnblogs.com/zacky31/p/9402072.html
Copyright © 2011-2022 走看看