mysql -u root -h localhost -p #登录

use mysql; #打开mysql数据库

select host,user from user where user='root'; #查看user表里的root数据

update user set host='%' where user='root' and host='localhost'; #将host设置为%表示任何ip都能连接mysql,也可以将host指定为某个ip

update user set host='localhost' where user='root’; #关闭远程连接,重新设置为localhost

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; #给root进行授权

flush privileges;  #刷新权限表,使配置生效

 

相关文章:

  • 2021-11-20
  • 2021-04-18
  • 2021-11-02
  • 2021-11-14
  • 2021-08-01
  • 2022-01-22
  • 2021-09-24
猜你喜欢
  • 2021-08-19
  • 2022-12-23
  • 2021-08-14
  • 2022-01-06
  • 2022-02-01
  • 2021-11-23
相关资源
相似解决方案