• mysql远程连接


    多人开发时,每人一份程序文件。但是有时需要公用一个份数据库。这时就需要数据库能远程连接。

    现在以mysql为例演示一下。

    这里远程连接可以

    1.允许固定客户端ip登陆。

    select host,user,password from mysql;

    mysql> select host,user,password from user;
    +-----------+------+----------+
    | host      | user | password |
    +-----------+------+----------+
    | localhost | root |          |
    | linux     | root |          |
    | localhost |      |          |
    | linux     |      |          |
    | localhost | pma  |          |
    +-----------+------+----------+
    5 rows in set (0.00 sec)
    

    对root进行赋权限

    A.grant select,update,insert,delete on *.* to root@192.168.0.110 identified by "";

    这样root用户就可以在192.168.0.110机器上登陆了。

    mysql> grant select,update,insert,delete on *.* to root@192.168.0.110 identified
     by "";
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select host,user,password from user;
    +---------------+------+----------+
    | host          | user | password |
    +---------------+------+----------+
    | localhost     | root |          |
    | linux         | root |          |
    | localhost     |      |          |
    | linux         |      |          |
    | localhost     | pma  |          |
    | 192.168.0.110 | root |          |
    +---------------+------+----------+
    6 rows in set (0.00 sec)
    

      

    B.grant all privileges on *.* to root@'%' identified by "";

    这样root用户就可以在任何ip的客户端登陆,并且有all privileges。

    mysql> grant all privileges on *.* to root@'%' identified by "";
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select host,user,password from mysql;
    ERROR 1146 (42S02): Table 'mysql.mysql' doesn't exist
    mysql> select host,user,password from user;
    +---------------+------+----------+
    | host          | user | password |
    +---------------+------+----------+
    | localhost     | root |          |
    | linux         | root |          |
    | localhost     |      |          |
    | linux         |      |          |
    | localhost     | pma  |          |
    | 192.168.0.110 | root |          |
    | %             | root |          |
    +---------------+------+----------+
    7 rows in set (0.00 sec)
    

      mysql> grant select,update,insert,delete on *.* to root@'%' identified by "";

    Query OK, 0 rows affected (0.00 sec)
    
    mysql> select host,user,password from user;
    +---------------+------+----------+
    | host          | user | password |
    +---------------+------+----------+
    | localhost     | root |          |
    | linux         | root |          |
    | localhost     |      |          |
    | linux         |      |          |
    | localhost     | pma  |          |
    | 192.168.0.110 | root |          |
    | %             | root |          |
    +---------------+------+----------+
    7 rows in set (0.00 sec)
    mysql> flush privileges;

      

    可以看出格式为 grant PRIVILEGES on DATEBASE.TABLE to USER@HOST identified by PASSWORD;

    而且这条语句也可以增加用户。

    如果感觉不错,请 一个!
    by simpman
  • 相关阅读:
    ① ts基础
    ⑦ 原型和原型链 作用域链
    ④ 小程序使用分包
    功能⑦ 小程序整合高德地图定位
    effective OC2.0 52阅读笔记(三 接口与API设计)
    effective OC2.0 52阅读笔记(二 对象、消息、运行期)
    effective OC2.0 52阅读笔记(一 熟悉Objective-C)
    perl的Getopt::Long和pod::usage ?
    安装你自己的perl modules
    Perl 之 use(), require(), do(), %INC and @INC
  • 原文地址:https://www.cnblogs.com/simpman/p/3213722.html
Copyright © 2020-2023  润新知