Mysql的版本是8.0.18,其他版本未验证
1. 新增用户
// 切换数据库到mysql
mysql> use mysql
// testUser:新增的用户名;localhost:仅本地访问,也可以是%(不限制)或者ip地址;123456:用户密码
mysql> create user 'testUser'@'localhost' identified by '123456';
2. 刷新权限
mysql> flush privileges;
3. 赋予权限
mysql> grant all privileges on *.* to 'testUser'@'localhost' with grant option;
4. 查看
mysql> select Host,User from user;