码迷,mamicode.com
首页 > 数据库 > 详细

MySQL权限设置

时间:2016-08-26 15:52:59      阅读:295      评论:0      收藏:0      [点我收藏+]

标签:mysql




本机访问权限:

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘username‘@‘localhost‘ IDENTIFIED BY ‘password‘;


远程访问权限:

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘username‘@‘%‘ IDENTIFIED BY ‘password‘;



FLUSH PRIVILEGES;



增加用户 test1 密码 abc,让它可以在任何主机上登录,并对所有数据库有查询,插入,修改,删除的权限:

 格式: grant select on 数据库.* to 用户名@登录主机 identified by "密码"


 grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";



删除用户

drop user root@localhost;(@不加默认为“%”)


权限回收

revoke delete on test.* from admin@‘localhost‘;



授权精确到列

grant select (cur_url,pre_url) on dataname.table_name to admin@localhost;




限制用户资源

mysql> GRANT ALL ON customer.* TO ‘francis‘@‘localhost‘

-> IDENTIFIED BY ‘frank‘

-> WITH MAX_QUERIES_PER_HOUR 20

-> MAX_UPDATES_PER_HOUR 10

-> MAX_CONNECTIONS_PER_HOUR 5

-> MAX_USER_CONNECTIONS 2;


本文出自 “比尔运维笔记” 博客,请务必保留此出处http://chenshoubiao.blog.51cto.com/6159058/1842667

MySQL权限设置

标签:mysql

原文地址:http://chenshoubiao.blog.51cto.com/6159058/1842667

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!