MySql 创建用户

MySql 命令窗口创建用户,经常用所以记录在这里
1、用管理员登陆mysql
2、创建数据库create database db01;
3、创建用户
CREATE USER username@’%’ IDENTIFIED BY ‘password’ ; –远程访问
CREATE USER username@’localhost’ IDENTIFIED BY ‘password’ ;– 本地访问
4、修改密码
SET PASSWORD FOR ‘username’@’localhost’ = PASSWORD(‘password2’);
5、授权
(1)授全部权限
GRANT ALL PRIVILEGES ON db01.* TO ‘username’@’localhost’;
(2)查看权限,并修改密码
GRANT SELECT ON *.* TO ‘username’@’%’ IDENTIFIED by ‘newpassword’;

— 花花整理