如何设置mysql允许外部连接访问
作者:罗丝丁 时间:2024-01-15 05:22:14
1.设置mysql允许外部连接访问(授权):
grant all privileges on *.* to root@'%' identified by '123456' with grant option;
flush privileges;
例子:
查询mysql用户权限、授权、刷新使生效
select host, user from user;
grant all privileges on *.* to root@'%' identified by '密码' with grant option;
flush privileges;
指定ip地址授权:ip地址指的是连接时失败报错1130弹出的地址
grant all privileges on *.* to root@'ip地址' identified by '密码' with grant option;
flush privileges;
没有权限:
连接成功:
注:不管使用navicat还是命令窗口,都是去操作mysql库中的user
1,可以使用navicat工具进入到数据库中mysql库执行语句;
2,使用命令执行,进入到命令窗口,登录到mysql服务器进入到mysql库(use mysql)中,执行以上授权语句即可。
连接服务器:
mysql -u root -p
进入mysql数据库:
use mysql;
查看user表中的数据:
select Host, User,Password from user;
第一种:修改user表的方法
修改user表中的Host:
update user set Host='%' where User='root';
第二种:授权的方法:将上面代码换为授权的代码即可;
grant all privileges on *.* to root@'%' identified by '密码' with grant option;
最后刷新一下:
flush privileges;
2.设置mysql允许外部连接访问(修改表的方法):
update user set Host='%' where User='root';
flush privileges;
来源:https://blog.csdn.net/XG17_38241417145/article/details/122668368
标签:mysql,外部,连接
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python中逻辑与或(and、or)和按位与或异或(&、|、^)区别
2023-07-05 23:02:34
![](https://img.aspxhome.com/file/2023/7/107577_0s.png)
python实现五子棋双人对弈
2023-11-14 05:36:10
![](https://img.aspxhome.com/file/2023/7/114567_0s.jpg)
10个提高网站可用性的实用技巧[译]
2009-06-12 12:37:00
![](https://img.aspxhome.com/file/UploadPic/20096/12/e110ff69d4158da954232063c6e0f6d7-48s.jpeg)
SQL 尚未定义空闲 CPU 条件 - OnIdle 作业计划将不起任何作用
2024-01-18 18:22:58
![](https://img.aspxhome.com/file/2023/4/108494_0s.png)
关于Python下的Matlab函数对应关系(Numpy)
2023-03-15 07:25:32
![](https://img.aspxhome.com/file/2023/6/120866_0s.png)
vscode的几项基本配置详解
2022-05-13 23:28:29
![](https://img.aspxhome.com/file/2023/8/117528_0s.png)
通过实例了解python__slots__使用方法
2023-03-16 13:24:50
python在Windows8下获取本机ip地址的方法
2023-07-31 17:10:44
基于RequireJS和JQuery的模块化编程日常问题解析
2024-04-19 10:17:04
![](https://img.aspxhome.com/file/2023/4/135864_0s.png)
js实现类似iphone的网页滑屏解锁功能示例【附源码下载】
2024-04-16 09:24:09
![](https://img.aspxhome.com/file/2023/1/136691_0s.png)
Python实现常见数据格式转换的方法详解
2023-04-16 03:48:16
![](https://img.aspxhome.com/file/2023/0/115880_0s.png)
python模拟表单提交登录图书馆
2021-11-06 19:20:42
![](https://img.aspxhome.com/file/2023/5/65935_0s.png)
详解Windows下源码编译PaddlePaddle
2022-07-06 00:22:09
![](https://img.aspxhome.com/file/2023/6/70776_0s.png)
python脚本定时发送邮件
2023-08-07 16:36:02
![](https://img.aspxhome.com/file/2023/0/59290_0s.jpg)
Matplotlib 生成不同大小的subplots实例
2022-12-22 03:16:26
![](https://img.aspxhome.com/file/2023/0/134920_0s.jpg)
SQL Server 2005数据库批量更新解决办法
2009-04-11 16:12:00
利用Python中的内置open函数读取二进制文件
2022-02-26 21:00:47
python 负数取模运算实例
2022-06-17 00:50:49
![](https://img.aspxhome.com/file/2023/0/72760_0s.jpg)
Python Mysql数据库操作 Perl操作Mysql数据库
2024-01-20 11:07:43
vue 过滤、模糊查询及计算属性 computed详解
2024-05-09 09:53:30
![](https://img.aspxhome.com/file/2023/1/127161_0s.png)