Mysql指定用户和设置用户访问表权限

1:创建用户

create user 'username'@'%' identified by 'password';

例:create user 'test_security'@'%' identified by '123456';

2:设置权限

GRANT privilege ON dbname.tablename TO 'username'@'%' IDENTIFIED BY "password";

例:grant all on test_security.* to 'test_security'@'%' identified by '123456';

3:刷新权限

flush privileges;

 4:查看用户权限

show grants for 'test_security'@'%';

 5:MYSQL8设置

不要修改root的权限,新增一个用户用来外部链接

CREATE USER 'admin'@'%' IDENTIFIED BY '123456!';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%';
FLUSH PRIVILEGES;

 

posted @ 2022-12-23 13:39  鸭猪是的念来过倒  阅读(161)  评论(0)    收藏  举报