mysql -u root -p use mysql; update user set host='ip' where user='root'; //更新访问权限 flush privileges; //更新数据库 /etc/init.d/mysql stop //停止服务 /etc/init.d/mysql start //开启服务 关闭linux防火墙. 安装:apt-get install ufw 关闭:ufw disable # To disable the firewall 开启:
环境:在VirtualBox中安装了Ubuntu虚拟机,网络使用了NAT模式,开启了端口转发. 局域网内其他计算机访问虚拟机中的MySQL Server出现两个问题: Lost connection to MySQL server at 'reading initial communication packet, system error: 0 以及 host is not allowed to connect mysql 1.解决Lost connection to MySQL server
登陆要链接的服务器上的mysql 命令:mysql -uroot -p123456 然后执行 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; 'root'@'%':mysql的用户名, %带代表任意的ip都可访问 好了成功