mysql 基础知识(4) - 用户和权限


Author: yifei / Created: Nov. 13, 2017, 10:32 p.m. / Modified: Nov. 13, 2017, 10:34 p.m. / Edit

创建用户

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';

授权

GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%' identified by 'password';

其中的 % 代表这个用户可以在任意主机登录.

SHOW GRANTS FOR newuser

用来显示一个用户的当前授权

set password for USERNAME = password('xxx')

更改用户密码

重置密码

sudo mysqld_safe --skip-grant-tables --skip-networking &
 
use mysql;
update user set authentication_string=PASSWORD("") where User='root';
update user set plugin="mysql_native_password"; # THIS LINE
flush privileges;
quit;

其他问题

EXPLAIN, slow-log


评论区