授权指定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 @   会飞的斧头  阅读(537)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示