开发者

Can't Connect to MYSQL via PHP [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I've tried connecting to mysql via my registered server on dreamhost, and via localhost. Neither one seems to work. I know I'm giving the proper data for user and such, but all I get is a dead connection.

I'm running Ubuntu 11.04...

edit

Ok, sorry for the lack of description. I have added my ip to the Dreamhost control panel. My code resembles th开发者_高级运维e following:

 define('SERVER', 'mysql.hostname.com');
        define('USERNAME', 'xxxxx');
        define('PASSWORD', 'xxxxx');

        $connection = mysql_connect(SERVER, USERNAME, PASSWORD) or die("error, cannot connect to mysql.");

when I do a var_dump() on the variable, all I get is a simple

bool(false)


Well, I'm not sure this strictly belongs here, and I'd really like more information about, say, the specific PHP code you're using to log in, but here are a few gotchas with Dreamhost, just in case they happen to match your particular issue:

  1. The mysql server is not localhost or your web server's domain. Instead, it's usually mysql.mydomain.com. Check your specific MySQL settings in the Dreamhost control panel.
  2. If you try to connect from another computer, you will be rejected unless that IP address has specifically been added in the MySQL section of Dreamhost's control panel. I noted you tried via localhost, but note that, even if you're trying the right server as per suggestion #1, you'll still get bum results from your personal computer unless the IP is whitelisted.


For the one on dreamhost, unless you specify that connections can be accepted from your local ip, it will not work. Read up on Mysql Access Control here

As for localhost, it should connect, but you need to provide more information on what your setup is i.e. whether you are connecting through -hhostname or just connecting through a local socket. Also what do you mean by "dead connection".

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜