zoukankan      html  css  js  c++  java
  • 解决远程连接数据库:Host is not allowed to connect to this MySQL server

    远程连接数据时,报以下提示:

    Host 'web1' is not allowed to connect to this MySQL server

    原因是数据库服务不允许远程登录,没有授权导致,解决方法如下:

    登陆mysql数据库:

    mysql –uroot –p123456

    创建并授权一个专用的数据库wordpress用于存放blog数据:

    create database wordpress;

    show database like ‘wordpress’;

    grant all on worpress.* to worpress@'localhost' identified by '123456';

    注:当数据库和php服务不在同一台机器上,可执行如下命令授权

    grant all on wordpress.* to wordpress@’192.168.0.%’ identified by ‘123456’;

    刷新权限,使得创建的用户生效:

    flush privileges;   

    查看用户对应的权限:

    select user,host from mysql.user where user='wordpress';  

    [root@mysql ~]# mysql -uroot -p123456
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 2
    Server version: 5.5.32 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2013, 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.
    
    mysql> create database wordpress;
    Query OK, 1 row affected (0.00 sec)
    mysql> grant all on wordpress.* to wordpress@'192.168.0.%' identified by '123456';
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select user,host from mysql.user where user='wordpress';
    +-----------+-------------+
    | user      | host        |
    +-----------+-------------+
    | wordpress | 192.168.0.% |
    +-----------+-------------+
    1 row in set (0.00 sec)

    测试效果:

     

  • 相关阅读:
    关于 拼接 url 连接 参数的问题(爬虫)。
    date 时间确定
    JavaScript跨域解决方法大全
    JS的 try catch使用心得
    博客要搬家啦!
    bzoj 3676: [Apio2014]回文串 -- 回文自动机
    bzoj 2631: tree -- LCT
    bzoj 2002: [Hnoi2010]Bounce 弹飞绵羊 -- LCT
    bzoj 2648: SJY摆棋子&&2716: [Violet 3]天使玩偶 --kdtree
    bzoj 1978: [BeiJing2010]取数游戏 game -- dp
  • 原文地址:https://www.cnblogs.com/su-root/p/11371197.html
Copyright © 2011-2022 走看看