mysql设置外网访问windows_如何允许Windows Server上的MySQL进行外部远程访问?

作者在Windows Server 2008 R2上安装了XAMPP,并尝试通过外部计算机连接到MySQL数据库。尽管已经尝试修改配置文件并创建新用户,但仍遇到连接失败的问题。错误提示表明可能是由于主机未响应导致的。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

bd96500e110b49cbb3cd949968f18be7.png

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...

解决方案

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:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值