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数据库,就可以了。

  • 相关阅读:
    【剑指offer】一些简单题05 06
    【剑指offer】11 旋转数组的最小数字
    【剑指offer】10 斐波那契数列
    【剑指offer】 03 数组中重复的数字
    【剑指Offer】 04 二维数组中的查找
    HPCC复习部份
    软工提纲复习
    软件工程复习
    Scala
    [转]对TCP/IP网络协议的深入浅出归纳
  • 原文地址:https://www.cnblogs.com/zacky31/p/9402072.html
Copyright © 2011-2022 走看看