当前位置:网站首页>mysql数据库的授权访问
mysql数据库的授权访问
2022-07-24 05:19:00 【hongdi】
目录
一、问题和解决思路
在部署好mysql后序号进行访问。但默认情况下mysql只允许本地电脑访问,网络中的其他电脑时无法访问下。如何解决呢?这时就需要向mysql数据库里的“user”表里添加相关授权记录。
mysql在进行身份检查时,使用user表的Host, User和Password等3个字段。服务器只有在user表记录的Host和User列匹配客户端主机名和用户名并且提供了正确的密码时才授权连接。
在user表Host值的指定方法:
* Host值可以是主机名或IP号,或’localhost’指出本地主机。
* 可以在Host列值使用通配符字符“%”和“_”。
* Host值’%’匹配任何主机名,空Host值等价于’%’。它们的含义与LIKE操作符的模式匹配操作相同。例如,’%’的Host值与所有主机名匹配,而’%.mysql.com’匹配mysql.com域的所有主机。
二、举例说明
(一)具体案例
例:主机192.168.1.10需要使用newuser用户newpwd密码访问mysql服务器
第一步:进入mysql命令工作界面;
第二步:mysql>GRANT ALL PRIVILEGES ON *.* TO ‘newuser’@’192.168.1.10′ IDENTIFIED
BY ‘newpwd’ WITH GRANT OPTION;
第三步:mysql>flush privileges;
(二)语法说明
1.grant语法
grant 权限名(所有的权限用all) on 库名(*全部).表名(*全部) to ‘要授权的用户名’@’%’(%表示所有的IP,可以只些一个IP) identified by “密码”;
例子
mysql> grant all on *.* to '[email protected]%' identified by '123456';
Query OK, 0 rows affected (0.02 sec)
2.flush privileges作用
flush privileges 命令本质上的作用是将当前user和privilige表中的用户信息/权限设置从mysql库(MySQL数据库的内置库)中提取到内存里。MySQL用户数据和权限有修改后,希望在”不重启MySQL服务”的情况下直接生效,那么就需要执行这个命令。
例
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
边栏推荐
- Hurry in!! Take you to understand what is multi file, and easily master the usage of extern and static C language keywords!!!
- 关于DAO流动性双币质押挖矿开发原理分析
- 如何强制卸载Google浏览器,不用担心Google打开为白板,亲测有效。
- Mapboxgl + GeoServer configuration local map tutorial
- OpenGL simulates the process of a ball falling to the ground and bouncing up in real life. Draw a ball on the screen, and the ball will fall from top to bottom, hit the ground and bounce up again.
- Create a new UMI project, error: rendered more hooks or rendered fewer hooks
- PyCharm设置代码模板
- 在本地怎么使用phpstudy搭建WordPress网站
- Public chain Sui layer1 network
- MySQL误操作后如何快速恢复数据
猜你喜欢
随机推荐
Collection = = academic waste
函数多种类型
Geoserver自动化上传Shapefile
vscode配置autoprefixer
php的多选、单选结果怎么在前台显示?
B站视频评论爬取——以鬼灭之刃为例(并将其存储到csv中)
Substrate 技术及生态5月大事记 | Square One 计划启动,波卡上线 XCM!
How to forcibly uninstall Google browser? Don't worry about Google opening as a whiteboard. It's effective for personal testing.
There are three ways to create in Polkadot - parallel chain, parallel thread, and smart contract
Inventory Poka ecological potential project | cross chain characteristics to promote the prosperity of multi track
Canvas - rotate
jsp标签
pycharm 配置局域网访问,局域网无法访问解决办法
如何强制卸载Google浏览器,不用担心Google打开为白板,亲测有效。
canvas - 圆形
jsp标签02
Moonbeam orbiters program: provides a new way for collectors to participate in moonbeam and Moonriver
Keywords_ 01return
7. Draw a Bezier curve on the screen and smooth the curve with anti aliasing technology.
【百度地图API】您所使用的地图JS API版本过低,已不再维护,为保证地图基本功能 正常使用,请尽快升级到最新版地图JS API








