1. 创建用户
-- 登录root用户
mysql -uroot -py
-- 查询所有用户
select user,host from mysql.user;
-- add
create user 'username'@'host' identified by 'password';
-- delete
drop user 'username'@'host';
-- 查看当前用户
select current_user;
2. 远程链接数据库
解决:
-- 修改用户host为%
update mysql.user set host = '%' where user ='username';
flush privileges;
3. 授权
root创建的数据库,全权授予新用户
-- 授权
grant all on dbname.tablename [dbname.*] to 'username'@'host';
-- 撤销授权
revoke all on dbname.tablename [dbname.*] from 'username'@'host';
flush privileges;
https://blog.csdn.net/qq_49175846/article/details/116356268