相关疑难解决方法(0)

php无法连接到错误13的mysql(但命令行可以)

我在新安装的服务器上遇到了奇怪的情况,这次谷歌似乎无法帮助我.我无法从我的php代码连接到(远程)mysql.当我尝试从同一服务器上的命令行连接时,连接就会被触发.

无法连接:无法连接到'MYSQL.SERVER'上的MySQL服务器(13)

以下是命令行中的代码和连接尝试

[u1@bosko httpdocs]$ cat  test.php

<?
$link = mysql_connect('MYSQL.SERVER', 'testusersimon', '123456');
if (!$link) {
    die('Could not connect: ' .  mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

[u1@bosko httpdocs]$ mysql -h MYSQL.SERVER -utestusersimon --password=123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 352108
Server version: 5.0.45-community-nt-log MySQL Community Edition (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free …
Run Code Online (Sandbox Code Playgroud)

php apache

57
推荐指数
2
解决办法
5万
查看次数

标签 统计

apache ×1

php ×1