添加用户

CREATE USER ‘username’@’host’ IDENTIFIED BY ‘password’;

username是用户名
host是允许用户从哪里登录,”%”表示从任何来源都允许
password是登录密码可以为空

范例:
CREATE USER ‘test’@’localhost’ IDENTIFIED BY ‘123456’;
CREATE USER ‘test2’@’%’ IDENTIFIED BY ”;

删除用户

DROP USER ‘username’@’host’;

参数和添加用户对应

授权

GRANT grivileges ON dbname.tablename TO ‘username’@’host’;

grivileges是权限,所有权限为ALL
dbname是数据库名字
tablename是表名
这2个参数都可以为*

范例:
GRANT ALL PRIVILEGES ON . TO ‘test’@’%’;
GRANT SELECT,INSERT ON mydb.* TO ‘test2’@’localhost’;