1、创建用户
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
2、查看用户权限
SHOW GRANTS;
3、设置用户权限
GRANT privileges ON dbname.tablename TO 'username'@'host';
privileges可以是SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, ALL PRIVILEGES(以上所有权限)
不指定表可以使用dbname.*,不指定数据库可以使用*.*
4、删除用户权限
REVOKE privileges ON dbname.tablename FROM 'username'@'host'
privileges的值同上
5、刷新用户权限
FLUSH PRIVILEGES;