用PHP连接到远程MySQL服务器 [英] connect to remote mysql server with php

查看:96
本文介绍了用PHP连接到远程MySQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我需要使用这样的PHP或smt连接位于远程PC上的mysql数据库
两台PC均已连接到互联网
我使用xampp和win7

我知道我会用

hello,
i need to connect a mysql database which is on a remote PC using PHP or smt like that
both PC are connected to internet
i use xampp and win7

i know that i will use

mysql_connect("remote PC''s IP", "login name set up for my PC", "login password");


另外,远程PC应该授予我读写其mysql数据库的权限.
我做到了:


additionally, remote PC should give permission to me to read and write its mysql database.
i did this:

CREATE USER ''remote''@''%'' IDENTIFIED BY ''***'';

GRANT ALL PRIVILEGES ON * . * TO ''remote''@''%'' IDENTIFIED BY ''***'' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

CREATE DATABASE IF NOT EXISTS `remote` ;

GRANT ALL PRIVILEGES ON `remote` . * TO ''remote''@''%'';


但它不是固定的. mysql_connect(远程PC的IP",为我的PC设置的登录名",登录密码")给出错误:

警告:mysql_pconnect()[function.mysql-pconnect]:无法连接到C:\ xampp \ htdocs \中的''79.***.***.***''(10060)上的MySQL服务器baglan.php在第3行
无法连接到''79.***.***.***(10060)上的MySQL服务器

您能帮我解决这个问题吗?


再次问好

我按照你说的做了,但没有运气...
在我的数据库中,我的特权为

用户主机密码全局特权授予
mustafa%一些pswd所有特权是

并且我向Windows防火墙添加了端口10060和3306的入站规则

任何建议...


but it was not fixed. mysql_connect("remote PC''s IP", "login name set up for my PC", "login password") gives error:

Warning: mysql_pconnect() [function.mysql-pconnect]: Can''t connect to MySQL server on ''79.***.***.***'' (10060) in C:\xampp\htdocs\baglan.php on line 3
Can''t connect to MySQL server on ''79.***.***.*** (10060)

could you please help me about this issue


hello again

i did what you said but no luck...
in my database i have a privilege as

User Host Password Global privileges Grant
mustafa % some pswd all privileges yes

and i add an inbound rule to windows firewall for port 10060 and 3306

any advice...

推荐答案

首先要检查的是端口10060未被防火墙阻止.
The first thing to check is that the port 10060 isn''t blocked by a firewall.


这篇关于用PHP连接到远程MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆