注意:需关闭防火墙或者开放3306端口
service iptables stop #暂时关闭 chkconfig iptables off #设置成开启不自启 ========== /sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT #开启3306端口 /etc/rc.d/init.d/iptables save #保存配置 /etc/rc.d/init.d/iptables restart #重启服务远程登录会报如下错误:
首先查看用户表,发现登录主机是localhost,当然不能登录,把root用户的localhost设置为%,这样任意主机都可以连接。 mysql> use mysql; Database changed mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ 4 rows in set (0.00 sec) mysql> update user set host = '%' where user ='root';
再刷新一下:
flush privileges;这时该问题已解决,若报如下错误,则是版本加密方式的改变
登录后请依次执行如下命令:
use mysql; ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER; #更改加密方式 ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';#更新用户密码 FLUSH PRIVILEGES;#刷新权限再次连接成功:
Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx