授权指定ip访问mysql 服务器

 

授权指定ip访问访问

授权ROOT使用密码1234从应用服务器主机连接到mysql服务器

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'xxx.xxx.xxx.xxx' IDENTIFIED BY '1234' WITH GRANT OPTION;

mysql> flush privileges; 

 

MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> update mysql.user set host='localhost' where host='%';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]>
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> select host, user, password from mysql.user;
+-----------+------+----------+
| host | user | password |
+-----------+------+----------+
| localhost | root | |
| 127.0.0.1 | root | |
| ::1 | root | |
| localhost | | |
| localhost | pma | |
+-----------+------+----------+
5 rows in set (0.00 sec)

 

1、添加mysql远程访问权限给支付服务器47.104.1.31;
    mysql -uroot -e \
    "select user, password, host from mysql.user;\
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'47.104.1.31' IDENTIFIED BY '1' WITH GRANT OPTION;\
    update mysql.user set password='' where host='47.104.1.31';\
    flush privileges;\
    select user, password, host from mysql.user;"

    
    mysql -uroot -e \
    "select user, password, host from mysql.user;\
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.31.140.155' IDENTIFIED BY '1' WITH GRANT OPTION;\
    update mysql.user set password='' where host='172.31.140.155';\
    flush privileges;\
    select user, password, host from mysql.user;"

 

mysql授权任意地址访问

授权ROOT使用1234从任何主机连接到mysql服务器

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIEDBY '1234'WITH GRANT OPTION;

mysql> flush privileges; 
 
 
 
 
 
posted @ 2018-07-17 11:38  会飞的斧头  阅读(533)  评论(0编辑  收藏  举报