grant all privileges on 数据库名.* to '账号名'@'%' identified by '账号密码';
# 示例:
'''
数据库名:shuchengyi
账号名:shucheng
密码:shucheng
'''
grant all privileges on shuchengyi.* to 'shucheng'@'%' identified by 'shucheng';
# 如要授权的账户未被创建则自动创建该账号
# 就把账号授权的代码,用localhost替换%,本机就可以登录了
grant all privileges on shuchengyi.* to 'shucheng'@'localhost' identified by 'shucheng';
flush privileges
mysql -ushucheng -pshucheng
show databases; # 查看是否可见指定库,有则成功
mysql数据库配置问题:授权指定库给指定mysql账号访问
原文:https://www.cnblogs.com/shuchengyi/p/11228264.html