假设数据库名称叫test
下面创建test用户并分配test数据库的所有权限
1,创建用户和密码
CREATE USER 'test'@'%' IDENTIFIED BY '123456';
2,将test用户绑定到test数据库上
GRANT ALL PRIVILEGES ON test.* TO 'test'@'%' IDENTIFIED BY '123456';
3,赋予权限
-- 赋予所有权限 all表示拥有数据库所有权限,还有SELECT,INSERT,UPDATE,delete,drop,ALTER,create等等。
GRANT ALL ON test.* TO 'test'@'%' IDENTIFIED BY '123456';
-- 赋予增删改查权限
-- GRANT SELECT,DELETE,UPDATE,CREATE,DROP ON test.* TO 'test'@'%' IDENTIFIED BY '123456';
4,刷新权限
FLUSH PRIVILEGES;
下面是删除权限,和修改密码
1,删除权限
revoke all privileges,grant option from 'test'@'%';
2,刷新权限
flush privileges;
修改密码
set password for 'test'@'%' = password('654321');
参考:https://blog.csdn.net/qq_43050077/article/details/119739244