添加用户
mysql> use mysql;
mysql> insert into user
(host, user, authentication_string, select_priv, insert_priv, update_priv)
values('localhost', 'guest', md5('password123'), 'Y', 'Y', 'Y');
- 得到报错信息:
ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
- 该报错是因为MySQL默认配置了严格模式,该模式禁止通过
insert
的方式直接修改mysql库中的user表进行添加新用户,需要使用grant
语句。
- 新增用户,'guest’为用户名 ,'localhost’为host,'password123’为密码
mysql> create user 'guest'@'localhost' identified by 'password123';
- 赋予权限 select, insert, update, delete, create, drop
mysql> grant usage on *.* to 'guest'@'localhost' with grant option;
mysql> grant select, insert, update, delete, create, drop on *.* to 'guest'@'localhost' with grant option;
- 重新载入授权表
mysql> flush privileges
本文链接:MySQL新增用户