zoukankan      html  css  js  c++  java
  • mysql外部连接支持

    首先 确认 mysql配置文件my.cnf  是否监听ip支持

    # Instead of skip-networking the default is now to listen only on
    # localhost which is more compatible and is not less secure.
    bind-address           = 127.0.0.1  #这里默认监听本地localhost
    

    如果要让mysql监听到其他的地址,可以将bind-address = 127.0.0.1注释掉。 
    或者将bind-address = 0.0.0.0监听所有的地址。(我这里碰到的问题就是没有将mysql配置 监听开启)

    屏蔽掉之后再次运行代码又出现:Host '192.168.10.**' is not allowed to connect to this MySQL server 

    如果想让192.168.10.**能够连接到本地的这个数据库,要让数据库给其分配权限,登录mysql,执行:(username 和 password是登录mysql的用户名和密码)

    GRANT ALL PRIVILEGES ON *.* TO 'username'@'192.168.10.**' IDENTIFIED BY 'password' WITH GRANT OPTION;
    

    如果要想所有的外部ip地址都能够访问使用mysql,可以执行下面:

    GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
    

    之后执行刷新数据库:

    flush privileges;
    

    如果要查看用户的权限,可以执行:

    > show grants for 'root'@192.168.10.**
    

     

  • 相关阅读:
    pod间访问
    Android地图下钻(坑我好久)
    学习进度23
    学习进度22
    人月神话读后感03
    团队介绍
    人月神话读后感02
    学习进度21
    学习进度20
    学习进度19
  • 原文地址:https://www.cnblogs.com/wyaokai/p/14850165.html
Copyright © 2011-2022 走看看