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;