本文摘自PHP中文网,作者coldplay.xixi,侵删。
Mysql设置用户指定ip地址操作数据库的方法:使用grant函数,语法为【grant priv_type on mysql.user to 'user'@'host' identified by 'password' with】。

Mysql设置用户指定ip地址操作数据库的方法:
语法:
1 | grant priv_type on mysql.user to 'user' @ 'host' identified by 'password' with grant option;
|
priv_type:代表允许操作数据库的权限
user:代表数据库用户名
host:代表IP地址
password:代表设置的密码
1 | 刷新user权限表: flush privileges;
|
三、案例
1、设置所有数据库、所有表、任意ip可以连接数据库,授权给用户名ping并设置密码为123456
1 2 | grant all on *.* to 'ping' @ '%' identified by '123456' ;
flush privileges;
|
2、授权表cloud的记录修改权限给连接ip地址是192.168.100.1和用户名是ping并且密码为123456
1 2 | grant update(name,sex) on cloud to 'ping' @ '192.168.100.1' identified by '123456' ;
flush privileges;
|
四、查看数据库权限表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | mysql> select * from mysql.user where host= 'localhost' \G;
*************************** 1. row ***************************
Host: localhost
User:
Password:
Select_priv: N
Insert_priv: N
Update_priv: N
Delete_priv: N
Create_priv: N
Drop_priv: N
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
References_priv: N
Index_priv: N
Alter_priv: N
Show_db_priv: N
Super_priv: N
Create_tmp_table_priv: N
Lock_tables_priv: N
Execute_priv: N
Repl_slave_priv: N
Repl_client_priv: N
Create_view_priv: N
Show_view_priv: N
Create_routine_priv: N
Alter_routine_priv: N
Create_user_priv: N
Event_priv: N
Trigger_priv: N
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
|
更多相关免费学习推荐:mysql教程(视频)
以上就是Mysql如何设置用户指定ip地址操作数据库的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
mysql存储过程的创建、调用与管理详解
一分钟带你了解mysql ddl
怎么利用cmd进入mysql
mysql全文索引实现简单版搜索引擎实例代码
mysql优化特定类型的查询(代码示例)
mysql中常见的日志问题介绍
mysql实现linux下数据库目录迁移
mysql5.6主从复制(mysql数据同步配置)
mysql数学函数简明总结
linux下 mysql oracle 简单使用手册
更多相关阅读请进入《mysql》频道 >>
机械工业出版社
本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。
转载请注明出处:木庄网络博客 » Mysql如何设置用户指定ip地址操作数据库