mysql 新建用户、授权、远程访问

时间:2021-12-02 21:21:52

新建用户

insert into mysql.user(Host,User,Password) values("localhost","u",password("123"));
flush privileges;
grant all privileges on uDB.* to u@localhost identified by '123';
flush privileges;
grant select,update on uDB.* to u@localhost identified by '123';
flush privileges;
DELETE FROM user WHERE User="u" and Host="localhost";
flush privileges;

  

远程访问

update mysql.user set host = '%' where user = 'u';
grant all privileges on *.* to 'u'@'%' identified by '123'

  

权限回收

revoke privileges on dbname[.tbname] from username;