博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql局域网访问设置
阅读量:4287 次
发布时间:2019-05-27

本文共 1145 字,大约阅读时间需要 3 分钟。

局域网连接mysql报错: 

ERROR 1130: Host '192.168.0.220' is not allowed to connect to this MySQL server

解决方法:

可能是帐号不允许从远程登陆,只能在localhost。这个时候只要在localhost的那台电脑,登入mysql后,更改 "mysql" 数据库里的 "user" 表里的 "host" 项,从"localhost"改称"%" 或添加一个用户为“%”  。    

想让局域网中的所有机器都能连接MySQL数据库,首先要给MySQL开启远程连接的功能,在MySQL服务器控制台上执行MySQL命令:

grant all privileges on *.* to root@"%" identified by 'abc' with grant option;  

flush privileges;

 

其中上面两行代码的意思是给从任意ip地址连接的用户名为root,密码为abc的用户赋予所有的权限。其中的"%"为任意的ip地址,如果想设为特定的值也可以设定为特定的值(以通配符%的内容增加主机/IP地址,也可以直接增加IP地址)。

做完这些之后,局域网内的mysql服务器可以访问了。

实例1:

-- 创建用户 ---单个数据库授权 create user 'testone'@'localhost' identified by '123';grant all privileges on testone.* to testone ;-- 创建用户2create user 'testtwo'@'localhost' identified by '123';grant all privileges on *.*  to testtwo@'localhost';grant all privileges on *.*  to testtwo@'localhost';-- 授予用户 远程访问 grant all privileges on *.*  to wlliuxue@'%' identified by '123' with grant option;flush privileges;grant all privileges on *.*  to testone@'192.168.1.126' identified by '123' with grant option;flush privileges;grant all privileges on *.* to root@'%' identified by '123' with grant option;  flush privileges;

转载地址:http://tragi.baihongyu.com/

你可能感兴趣的文章
RingtoneManager铃声设置
查看>>
WifiManager设置
查看>>
PackageManager安装包管理
查看>>
Pixel,Bitmap,Drawable,Canvas,Paint,Matrix,BitmapDrawable,BitmapFactory图相关
查看>>
SQLLite常用代码
查看>>
Fragment
查看>>
android多线程,子线程与主线程的通信,下载的文件的显示
查看>>
王垠:对博士学位说永别
查看>>
王垠:人的价值
查看>>
android-Service
查看>>
Service通信(service介绍之二)
查看>>
Android学习计划
查看>>
自己测到的Buu IP
查看>>
何银青-利用上课时间,就给我打这么点代码
查看>>
yum配置与使用(很详细)
查看>>
yum的使用
查看>>
./configure 的配置和用法
查看>>
web.config
查看>>
web.xml
查看>>
web.xml(简介介绍)
查看>>