
第一步:首先设置root用户的host为所有IP:
进入Mysql:
mysql -uroot -pyoupass
进入后use mysql
然后,update user set host=’%’ where user=’root’ and host=’localhost’
flush privileges
上面这一步注意分号,设置完了可以 select user,host from user表看看,设置成功没。
第二步:
如果你是云服务器,要去设置my.cnf 把下面bind-address 设置成你的云服务器的外网IP。
这个问题,我有经验。程序没有错的情况下。先停止mysql服务,然后打开命令行。输入mysqld_safe --skip-grant-tables
然后输入 mysql -u root
然后修改密码update user set Password = PASSWORD('新密码') where User ='root'
当然,密码也可以不改
然后flus privileges接着quit退出
然后重启mysql。
搞定
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)