查看数据库的所有用户
select user,host from mysql.user;
查看一下用户的权限 root
show grants for root@'%';
移除一个用户的插入权限
revoke INSERT on 库名.* from '用户名'@'%';
删除一个用户的远程权限
Delete from user where user = "用户名" and host = "%" ;
修改用户的远程权限
update user set host = 'localhost' where user = 'admin';
增加数据库的用户权限
grant select on `库名`.* to '用户名'@'%';
GRANT ALL PRIVILEGES ON `库名`.* TO '用户名'@'%'
新建立一个用户,给一个库查看权限
grant select on 库名.* to '用户名'@'%' identified by '2bSXgc4*';
删除一个用户
删除用户:
>> delete from user where user='test' and host='localhost';
删除账户及权限:
>> drop user 用户名@'%';
>> drop user 用户名@ localhost; ;
root用户的访问设置
设置所有用户可以远程访问mysql,修改my.cnf配置文件,将bind-address = 127.0.0.1前面加“#”注释掉,这样就可以允许其他机器远程访问本机mysql了;
设置用户root,可以在远程访问mysql:
>> grant all privileges on *.* to root@"%" identified by "123456" ;
查询mysql中所有用户权限:
>> select host,user from user;
禁止root用户在远程机器上访问mysql:
>> delete from user where user="root" and host="%" ;