修改mysql权限
关于mysql的用户管理,笔记
1、创建新用户
通过root用户登录之后创建
>> grant all privileges on *.* to testuser@localhost identified by "123456" ; // 创建新用户,用户名为testuser,密码为123456 ;
>> grant all privileges on *.* to testuser@localhost identified by "123456" ; // 设置用户testuser,可以在本地访问mysql
>> grant all privileges on *.* to testuser@"%" identified by "123456" ; // 设置用户testuser,可以在远程访问mysql
>> flush privileges ; // mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权限相关表,否则会出现拒绝访问,还有一种方法,就是重新启动mysql服务器,来使新设置生效
2、设置用户访问数据库权限
>> grant all privileges on test_db.* to testuser@localhost identified by "123456" ; // 设置用户testuser,只能访问数据库test_db,其他数据库均不能访问 ;
>> grant all privileges on *.* to testuser@localhost identified by "123456" ; // 设置用户testuser,可以访问mysql上的所有数据库 ;
>> grant all privileges on test_db.user_infor to testuser@localhost identified by "123456" ; // 设置用户testuser,只能访问数据库test_db的表user_infor,数据库中的其他表均不能访问 ;
3、设置用户操作权限
>> grant all privileges on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ; //设置用户testuser,拥有所有的操作权限,也就是管理员 ;
>> grant select on *.* to testuser@localhost identified by "123456" WITH GRANT OPTION ; //设置用户testuser,只拥有【查询】操作权限 ;
>> grant select,insert on *.* to testuser@localhost identified by "123456" ; //设置用户testuser,只拥有【查询\插入】操作权限 ;
>> grant select,insert,update,delete on *.* to testuser@localhost identified by "123456" ; //设置用户testuser,只拥有【查询\插入】操作权限 ;
>> REVOKE select,insert ON what FROM testuser //取消用户testuser的【查询\插入】操作权限 ;
4、设置用户远程访问权限
>> grant all privileges on *.* to testuser@“192.168.1.100” identified by "123456" ; //设置用户testuser,只能在客户端IP为192.168.1.100上才能远程访问mysql ;
5、关于root用户的访问设置
设置所有用户可以远程访问mysql,修改my.cnf配置文件,将bind-address = 127.0.0.1前面加“#”注释掉,这样就可以允许其他机器远程访问本机mysql了;
>> grant all privileges on *.* to root@"%" identified by "123456" ; // 设置用户root,可以在远程访问mysql
>> select host,user from user; //查询mysql中所有用户权限
关闭root用户远程访问权限
>> delete from user where user="root" and host="%" ; //禁止root用户在远程机器上访问mysql
>> flush privileges ; //修改权限之后,刷新MySQL的系统权限相关表方可生效
修改mysql权限的更多相关文章
- 【mysql创建用户|删除用户|修改用户权限|常用命令】
原文链接:http://blog.csdn.net/leili0806/article/details/8573636 1. CREATE USER 语法: CREATE USER 'us ...
- 修改mysql允许主机访问的权限
开启mysql的远程访问权限 默认mysql的用户是没有远程访问的权限的,因此当程序跟数据库不在同一台服务器上时,我们需要开启mysql的远程访问权限. 主流的有两种方法,改表法和授权法. 相对而言, ...
- mysql 权限的相应修改
mysql 权限的相应修改 UPDATE user SET Password = PASSWORD('bbbb') WHERE user = 'root';flush privileges; upda ...
- MySQL 权限与安全
一.MySQL权限系统通过两个阶段进行认证: (A) 对用户进行身份认证,IP地址和用户名联合, (B) 对合法用户赋予相应权限,权限表在数据库启动的时候载入内存中. 二.在权限的存取过程中,会用到& ...
- mysql权限与安全
一.MySQL权限系统通过两个阶段进行认证: (A) 对用户进行身份认证,IP地址和用户名联合, (B) 对合法用户赋予相应权限,权限表在数据库启动的时候载入内存中. 二.在权限的存取过程中,会用到& ...
- MYSQL权限表user操作
MYSQL权限表user cmd中进人mysql找到mysql安装目录 E:\wamp\bin\mysql\mysql5.6.12\bin>mysql.exe -u 用户名 - ...
- Windows如何修改MySQL用户root密码
听语音 浏览:16925 | 更新:2015-06-12 14:49 | 标签:windows 1 2 3 4 5 6 分步阅读 MySQL是一个关系型数据库管理系统,在 WEB 应用方面 MySQL ...
- Mysql权限
连接Oracle/Mysql数据库的配置 1.Oracle <context:property-placeholder location="jdbc.properties"/ ...
- 【MySQL学习笔记】MySQL权限表
MySQL权限表,控制用户对数据库的访问,存在mysql数据库中,由mysql_install_db初始化,包括user,db,host,tables_priv,columns_priv,procs_ ...
随机推荐
- Windows系统Unity3D中的快捷键
Windows系统Unity3D中的快捷键 组合键 键 功能 File 文件 Ctrl N New Scene 新建场景 Ctrl O Open Scene 打开场景 Ctrl S Sav ...
- 【SPOJ - GSS2】Can you answer these queries II(线段树)
区间连续不重复子段最大值,要维护历史的最大值和当前的最大值,打两个lazy,离线 #include<cstdio> #include<cstring> #include< ...
- BZOJ2830 & 洛谷3830:[SHOI2012]随机树——题解
https://www.luogu.org/problemnew/show/P3830#sub <-题面看这里~ https://www.lydsy.com/JudgeOnline/prob ...
- Static全局变量与普通的全局变量有什么区别?static函数与普通函数有什么区别?
Static全局变量与普通的全局变量有什么区别? 答: 全局变量(外部变量)的说明之前再冠以static就构成了静态的全局变量.全局变量本身就是静态存储方式,静态全局变量当然也是静态存储方式. 这两者 ...
- BZOJ4105 [Thu Summer Camp 2015]平方运算 【线段树】
题目链接 BZOJ4105 题解 平方操作orz,虽说应该是线段树,但是不会维护啊QAQ 小瞧一眼题解... 平方成环?环长\(lcm\)小于\(60\)? 果然还是打表找规律题.... 那就很好做了 ...
- javascript实现deepEqual和shallowEqual
function deepEqual(x, y) { if (x === y) { return true; } if (!(typeof x == "object" && ...
- Codeforces Round #330 (Div. 2) B. Pasha and Phone
B. Pasha and Phone time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Atlantis HDU - 1542 (线段树扫描线)
There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some ...
- zabbix问题汇总
1. ::110809.577 resuming IPMI checks on host [10.1.3.41]: connection restored :: seconds :: seconds ...
- iptables使用总结
推荐博文: http://www.zsythink.net/archives/1199 http://www.cnblogs.com/migongci0412/p/5198370.html 总结: 1 ...