新建用户

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;