How to allow MySQL on Windows Server for external remote access?

♀尐吖头ヾ 提交于 2019-12-07 12:08:44

问题


i have installed xampp on my windows server 2008 R2. I'm running a script there that stores me data over the day. Now i want to retrieve the data from my own computer or just external by connecting the database via mysql_connect("hostname","username","pw"). after some research i have got told that i have to commend

> [...]
> #bind-address = 127.0.0.1
> #skip-networking 
  [...]

in /etc/mysql/my.cnf

didn't find the my.cf file in mysql but found one in xampp/mysql/bin/my.ini . But when i opened the file i found the lines even commented so hadn't got to change anything..... strange.

then i got told to create a new user with the host setted %. So i did. now i tried to acces the database on my pc (xampp) but when i want to connect the database, i just get the error message, that the connection failured. Where is the mistake ?

thanks

edit:

thats howi exactly connect

$connection=mysql_connect("hostname","usrname","password")or die(mysql_error());
mysql_select_db("dbname")or die(mysql_error());

and the error message i get is german you can trabslate.

Warning: mysql_connect(): Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat. in C:\xampp\htdocs\tickerdata\get.php on line 4

just means as much as connection failured because remote didnt react in certain time period or connection was faulty because host didnt react...


回答1:


If you can't connect to the server remotely, but you can connect locally, you either need to open port 3306 in the firewall, or grant the user permissions from the remote IP.

The port should be opened in the windows firewall, as well as the router firewall. Your router will need to forward the port to the 2008R2 server.

To open ports in 2008R2 firewall:

http://www.2x.com/blog/2010/04/tech/configuring-the-windows-server-2008-r2-firewall-to-open-ports-for-2x-solutions/

To grant user permissions on IP:

GRANT ALL ON foo.* TO bar@'255.255.255.255' IDENTIFIED BY 'PASSWORD';

Keep in mind that it is possible to have duplicate usernames in MySQL, and if you didn't create the new user with a UNIQUE username then you may be getting the privileges of the user jailed to localhost



来源:https://stackoverflow.com/questions/14295287/how-to-allow-mysql-on-windows-server-for-external-remote-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!