2005未​​知的MySQL服务器主机' 127.0.0.1:3306' (11001)'

时间:2018-01-12 12:26:39

标签: php mysql apache pdo

对,

我有以下错误:

  

致命错误:未捕获的异常' PDOException'消息' SQLSTATE [HY000] [2005]未知的MySQL服务器主机' 127.0.0.1:3306' (11001)'在C:\ xampp \ htdocs \ php.php:5堆栈跟踪:#0 C:\ xampp \ htdocs \ php.php(5):PDO-> __ construct(' mysql:host = 127 ... 。',' root','传递')#1 {main}在第5行的C:\ xampp \ htdocs \ php.php中抛出

php.php包含以下内容:



error_reporting(E_ALL);
ini_set('display_errors', 1);

/* Database Setting */
$db['host'] = '127.0.0.1'; //Mysql's Host
$db['port'] = '3306'; //Mysql's port
$db['user'] = "root"; //Mysql's user
$db['pass'] = 'pass'; //Mysql's password
$db['db'] = "db"; //Mysql's database

$dbh = new PDO('mysql:host='.$db['host'].':'.$db['port'].';dbname='.$db['db'].'', $db['user'], $db['pass']);




我发现了其他一些帖子,但是那些帖子出现了同样的错误,但随后localhost而不是127.0.0.1这真的很奇怪,你能帮助我吗?

谢谢!

0 个答案:

没有答案