Home > Database > Mysql Tutorial > body text

ubuntu mysql远程连接问题解决方法_MySQL

WBOY
Release: 2016-06-01 13:36:14
Original
899 people have browsed it

Ubuntu

bitsCN.com


  今天在配置opennebula 3.8的时候,当执行one start启动时,报不能连接数据库的错误,
但是在shell下输入mysql -uroot -p是可以登录的,所以问题应该是mysql不允许root用户远程
登录的问题,于是通过输入下面命令:


GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'password' WITH GRANT
OPTION;

重启mysql后,发现还是连不上,于是想到是不是防火墙(ufw)或是iptables禁用了3306端口。
通过service iptables stop和ufw status,查看发现并不是防火墙或iptables的问题,而且通过
netstat可以看到3306端口处于监听状态。

   排除了以上因素之后,又google了下,发现问题出现mysql的配置文件my.cnf中,通过如下
修改,重启mysql后,成功远程登录,opennebula成功连上mysql数据库。


sudo vim /etc/mysql/my.cnf
//找到如下内容,并注释
bind-address = 127.0.0.1   注释掉 bind-address = 127.0.0.1 后重启mysql即可!如果不注
释掉,通过netstat可以查看到,306端口只是在IP 127.0.0.1上监听,所以拒绝了其他IP的访问。

ubuntu mysql远程连接问题解决方法_MySQL

 


bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!