1.管理员对指定账号进行授权

grant all privileges on 数据库名.* to '账号名'@'%' identified by '账号密码';

# 示例:
'''
数据库名:shuchengyi
账号名:shucheng
密码:shucheng
'''
grant all privileges on shuchengyi.* to 'shucheng'@'%' identified by 'shucheng';

# 如要授权的账户未被创建则自动创建该账号

2.如果本机连mysql连不上

# 就把账号授权的代码,用localhost替换%,本机就可以登录了
grant all privileges on shuchengyi.* to 'shucheng'@'localhost' identified by 'shucheng';

3.设置完之后一定要刷新权限

flush privileges

4.退出管理员,用账号 luffy 密码 luffy 登入开发

mysql -ushucheng -pshucheng
show databases;  # 查看是否可见指定库,有则成功

相关文章:

  • 2022-12-23
  • 2021-08-08
  • 2021-10-04
  • 2021-10-04
  • 2022-12-23
  • 2021-07-06
  • 2021-12-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-11-22
  • 2022-01-08
  • 2021-12-05
相关资源
相似解决方案