创建用户和授权
1.创建用户:
# 指定ip:192.118.1.1的mjj用户登录
create user 'mjj'@'192.118.1.1' identified by '123';
# 指定ip:192.118.1.开头的mjj用户登录
create user 'mjj'@'192.118.1.%' identified by '123';
# 指定任何ip的mjj用户登录
create user 'mjj'@'%' identified by '123';
2.删除用户
drop user '用户名'@'IP地址';
3.修改用户
rename user '用户名'@'IP地址' to '新用户名'@'IP地址';
4.修改密码
set password for '用户名'@'IP地址'=Password('新密码');
*****进入mysql库, use mysql; 输入
select * from user\G;
查看所有用户*****
对当前的用户授权管理
查看权限
show grants for '用户'@'IP地址';
#授权 mjj用户仅对db1.t1文件有查询、插入和更新的操作
grant select ,insert,update on db1.t1 to "mjj"@'%';
# 表示有所有的权限,除了grant这个命令,这个命令是root才有的。mjj用户对db1下的t1文件有任意操作
grant all privileges on db1.t1 to "mjj"@'%';
#mjj用户对db1数据库中的文件执行任何操作
grant all privileges on db1.* to "mjj"@'%';
#mjj用户对所有数据库中文件有任何操作
grant all privileges on *.* to "mjj"@'%';
远程连接:
mysql -uskx -P3306 -h 192.168.15.113 -p1231.创建用户:
# 指定ip:192.118.1.1的mjj用户登录
cr