使用PHP的MySQL连接字符串 [英] MySQL Connection String Using PHP

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

问题描述

我正在尝试通过本地计算机连接到服务器上托管的数据库.

I am trying to connect to the database that is hosted on my server through my local machine.

我的服务器具有cPanel 11,它是一个典型的共享服务器,由CentOS,PHP和MySQL提供支持.

my server has cPanel 11, and it is a typical shared server, powered by CentOS, PHP and MySQL installed.

准确地说,我将转销商帐户保存在同一服务器中.我想访问不同帐户或域之间的数据库.

to be precise i am holding the reseller account in the same server. i want to access the database between different accounts or domains.

在MySQL连接字符串中,我尝试定义域名,但是它不起作用.这是我尝试过的.

in MySQL connection String i tried defining the domain name, and it isn't working. here is what i tried.

<?php
$link = mysql_connect('mydomain.com', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

这给出了以下错误

Warning: mysql_connect() [function.mysql-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://bhatkalnews.com:3306) in C:\wamp\www\test\conn.php on line 4

Warning: mysql_connect() [function.mysql-connect]: 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. in C:\wamp\www\test\conn.php on line 4

Fatal error: Maximum execution time of 60 seconds exceeded in C:\wamp\www\test\conn.php on line 4

我必须在连接字符串中定义什么才能使其正常工作?

what do i have to define in connection string to make it work?

推荐答案

防火墙?

尝试

telnet mydomain.com 3306

telnet mydomain.com 3306

在命令行上.

如果这不起作用,则很可能是防火墙阻止了连接

If that doesn't work, the connection is blocked by a firewall, most likely

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

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