美文网首页
mysql设置远程连接

mysql设置远程连接

作者: 踏云小子 | 来源:发表于2017-10-30 18:12 被阅读9次

    简单方法

    Show me the fucking code

    mysql -u root -p
    grant all privileges on *.* to root@"your ip address" identified by "password" with grant option;
    flush privileges;
    

    如果想省事,允许所有ip,直接用'%' grant all privileges on *.* to root@"%" identified by "password" with grant option;

    分析

     SELECT  host,user,password FROM user WHERE user = 'root';
    
    image.png

    结果发现host是'%'的用户密码不对,所以总是连接失败,需要改变密码

    UPDATE `user` SET Password=PASSWORD("new password") WHERE Host='%' AND User='root';
    flush privileges;
    

    重启mysql

    sudo service mysqld restart
    

    相关文章

      网友评论

          本文标题:mysql设置远程连接

          本文链接:https://www.haomeiwen.com/subject/cxdmpxtx.html