meng@localhost表示创建的账户只能在本机登录
grant只能创建有密码的账户。,不然会报1033错误
grant创建账户
grant all privileges on *.* to meng@localhost identified by '123' with grant option;
all privileges这个权限不要乱用,权限好高的
如果需要一个空密码或者无密码的账户,必须先用Create User命令,然后通过
grant来分配权限。
创建账号,赋予CRUD权限,从任何IP登录,密码123
grant select,insert,update,delete on test1.* to 'z2'@'%' identified by '123
收回权限
revoke select,insert on *.* from meng@localhost;
查看 账号权限
show grants for meng@localhost;
授予管理权限
grant super,process,file on *.* to 'z3'@'%';
只授予登录权限
grant usage on *.* to 'z4'@'localhost';
修改密码:
第一种:
shell>mysqladmin -u user_name -h host_name password "newpwd";
方法2:
mysql>set password for 'meng'@'%' = PASSWORD('laomeng123');
方法3:
grant usage on *.* to 'meng'@'%' identified by 'laomeng123';
改完密码后flush privileges;刷新用户权限
可以用MD5来代替明文密码
删除账号:
drop user meng@localhost;
或者
use mysql;
delete from user where user='meng'
mysql账号还支持账号资源限制,比如单个账号每小时执行的查询次数;比如单个账号每小时执行的更新次数;每小时连接服务器次数;
不要把SUPER、PROCESS和FILE授予管理员以外的角色
SUPER能执行KILL直接关进程,POCESS能锁定进程,能造成管理员密码被直接修改
显示INNODB状态及错误状态
show engine innodb status\G
grant只能创建有密码的账户。,不然会报1033错误
grant创建账户
grant all privileges on *.* to meng@localhost identified by '123' with grant option;
all privileges这个权限不要乱用,权限好高的
如果需要一个空密码或者无密码的账户,必须先用Create User命令,然后通过
grant来分配权限。
创建账号,赋予CRUD权限,从任何IP登录,密码123
grant select,insert,update,delete on test1.* to 'z2'@'%' identified by '123
收回权限
revoke select,insert on *.* from meng@localhost;
查看 账号权限
show grants for meng@localhost;
授予管理权限
grant super,process,file on *.* to 'z3'@'%';
只授予登录权限
grant usage on *.* to 'z4'@'localhost';
修改密码:
第一种:
shell>mysqladmin -u user_name -h host_name password "newpwd";
方法2:
mysql>set password for 'meng'@'%' = PASSWORD('laomeng123');
方法3:
grant usage on *.* to 'meng'@'%' identified by 'laomeng123';
改完密码后flush privileges;刷新用户权限
可以用MD5来代替明文密码
删除账号:
drop user meng@localhost;
或者
use mysql;
delete from user where user='meng'
mysql账号还支持账号资源限制,比如单个账号每小时执行的查询次数;比如单个账号每小时执行的更新次数;每小时连接服务器次数;
不要把SUPER、PROCESS和FILE授予管理员以外的角色
SUPER能执行KILL直接关进程,POCESS能锁定进程,能造成管理员密码被直接修改
显示INNODB状态及错误状态
show engine innodb status\G