网址无法连接到mysql,无法通过(IP或域名)连接到MySQL服务器

I'm trying to configure a web server (Debian 7). I followed this tutorial.

I'm renting my server thanks to gandi.net service. And i have now apache2, mysql, php5 up and running.

I connect to it using following command on terminal : ssh username@domainname.com

Next step is to create my database through sequel pro and I don't know how to do it and documentation is not so clear...

Here is what I'm talking about :

mfWFB.png

I have tried to connect :

Nom : some name, i found clear. (I think i can put anything in here, right ?)

Host : ip or domain name

User : the username I'm using in my ssh connection (cf above)

Password : the password I both use for ssh connection (cf above) and mysql connection

For the rest, I left like it was and I received this error message :

Unable to connect to host domainname.com, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Can't connect to MySQL server on 'domainename.com' (61)' (2)

Any idea how I could do that?

解决方案

If you do a normal install of MySQL on Debian, it will be configured to block external connections to the database.

This means that you still need to tell MySQL that external access is OK. To do this, you need to update the bind address for MySQL. This is configured in my.cnf, which, on Debian based systems, is located in /etc/mysql/my.cnf.

In there, find the section that says

[mysqld]

In there, you must make sure that

the line skip-networking is either commented (comments start with a '#') or not there, and

Bind-address is set to either 0.0.0.0 (which it is if there is no line bind-address) or to your server's IP-address.

After doing this, you should restart your MySQL service. Then you need to create a user that is allowed remote access. This can be done with a SQL query:

GRANT ALL ON yourdatabase.* TO youruser@'*' IDENTIFIED BY 'yourpassword';

You can switch out the asterisk for the IP-address you will connect from, if it's the same every time.

Finally , you need to open port 3306 (the port MySQL uses) on your firewall. This usually isn't neccesary as it is already open on most systems, but it can be done using the following iptables command.

/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT

service iptables save

Source: 1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值