mysql 如何新增用户,设置权限

#要列出用户
SELECT * FROM mysql.user;
#创建用户
CREATE USER user1
IDENTIFIED BY '628803c';
#更改密码
ALTER USER user1IDENTIFIED WITH mysql_native_password BY '6288031f';

#要显示权限:
show grants for 'user1';
#要更改权限,请先撤消。如:
revoke all privileges on *.* from 'user1';
#然后根据需要授予适当的权限:
grant SELECT,INSERT,UPDATE,DELETE ON `db`.* TO 'user1';
#最后,刷新:
flush privileges;

  

posted @ 2022-10-27 15:06  iDEAAM  阅读(69)  评论(0编辑  收藏  举报