zoukankan      html  css  js  c++  java
  • 本地连接远程环境mysql报错:Host'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server

      问题现象:本机连接远程环境的mysql数据库报错,提示本机ip无法连接到mysql服务器。

      问题原因:本机对远程mysql数据库没有访问权限。

      解决方法:在远程mysql数据库添加本机ip的访问权限:

      1、登陆远程mysql,这里的用户名和密码都是root

    [root@izwz932ypmamm80m434qqyz ~]# mysql -uroot -proot
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 20
    Server version: 5.5.55-log MySQL Community Server (GPL) by Atomicorp
    
    Copyright (c) 2000, 2017, 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.

      2、进入mysql数据库,查询用户表

    mysql> use mysql;
    Database changed
    mysql> select user,password,host from user;
    +------+-------------------------------------------+-------------------------+
    | user | password                                  | host                    |
    +------+-------------------------------------------+-------------------------+
    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | localhost               |
    | root |                                           | izwz932ypmamm80m434qqyz |
    | root |                                           | 127.0.0.1               |
    | root |                                           | ::1                     |
    |      |                                           | localhost               |
    |      |                                           | izwz932ypmamm80m434qqyz |
    +------+-------------------------------------------+-------------------------+
    6 rows in set (0.00 sec)

      3、添加本机ip(这里为117.149.10.46),用户名密码还是设置为root

    mysql> grant all privileges on *.* to root@"117.149.10.46" identified by "root";
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select user,password,host from user;                                     +------+-------------------------------------------+-------------------------+
    | user | password                                  | host                    |
    +------+-------------------------------------------+-------------------------+
    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | localhost               |
    | root |                                           | izwz932ypmamm80m434qqyz |
    | root |                                           | 127.0.0.1               |
    | root |                                           | ::1                     |
    |      |                                           | localhost               |
    |      |                                           | izwz932ypmamm80m434qqyz |
    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | 117.149.10.46           |
    +------+-------------------------------------------+-------------------------+
    7 rows in set (0.00 sec)

      4、重新加载mysql的访问权限

    mysql>flush privileges;

      本机重新连接远程mysql成功。

  • 相关阅读:
    u-boot 用哪个lds链接脚本
    u-boot-2019.07 移植步骤
    u-boot-2016.09 make编译过程分析(二)
    grep 命令搜索 带空格的字符
    uboot if_changed函数
    2019保险规划 待完善
    MongoDB Capped集合
    并发编程——详解 AQS CLH 锁
    Spring容器中的Bean几种初始化方法和销毁方法的先后顺序
    观察者模式
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/8067665.html
Copyright © 2011-2022 走看看