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成功。

  • 相关阅读:
    临时生成的文件下载“提速” (提早开始下载)(node.js)
    node.js http接口调试时请求串行特性分析
    presto 判断数据量是否大于一个比较小的值的优化
    typescript 关于class属性类型定义被属性默认值覆盖的问题及解决方式
    typescript 属性默认值使用箭头函数 this指向问题
    presto 函数中使用子查询
    浅谈redis的HyperLogLog与布隆过滤器
    关于管理后台更新与响应的设计
    对“算法-求二进制数中1的个数” 中一些要点的补充
    关于async 中return 和 return await 的差异
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/8067665.html
Copyright © 2011-2022 走看看