質問

I am hosting my own web server and am trying to access my MySQL database from my laptop (not the server). On my laptop I have added the following to the config.inc.php file:

$i++;
$cfg['Servers'][$i]['verbose'] = 'xx.xxx.xxx.xxx';
$cfg['Servers'][$i]['host'] = 'xx.xxx.xxx.xxx';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'nick';
$cfg['Servers'][$i]['password'] = 'xxxxxxx';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

I have created, on the server, a user named "nick" with all grants. I have tried a LOT of different configurations of the code above and I just cannot connect remotely.

The host IP is the IP of my router that is using a DNS linking it to the domain name, I would imagine it is the same host needed here. I am port forwarding 8080 for my website and using a port 80 rerout with the DNS. I get this error when trying to connect to the server from my laptop:

Error MySQL said: Documentation

2002 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

The server is not responding (or the local server's socket is not correctly configured).

Somebody please help, I do not want to spend forever on this :/ I'm supposed to be working on the website, not the MySQL remote connection haha!

役に立ちましたか?

解決 2

In Windows Firewall create an exception for port 3306. Make sure that the port is also being forwarded.

他のヒント

MySQL runs on port 3306, it sholdn't be blocked. It wasn't for me.

Then make sure that your mysql allows connections from the outside.

Just edit your my.cnf file

  • If you are using Debian Linux file is located at /etc/mysql/my.cnf location.
  • If you are using Red Hat Linux/Fedora/Centos Linux file is located at /etc/my.cnf location.
  • If you are using FreeBSD you need to create a file /var/db/mysql/my.cnf location.

    $ nano my.cnf

Go down until you find [mysqld]

[mysqld]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
language        = /usr/share/mysql/English
bind-address    = 65.55.55.2
# skip-networking

Modify "bind-address" to the ip of your server so that it listens on it (it is default to localhost).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top