美文网首页
SQLSTATE[HY000] [2002] Connectio

SQLSTATE[HY000] [2002] Connectio

作者: panw3i | 来源:发表于2018-01-04 10:38 被阅读170次

如果使用 docker $serverName 使用本机ip

<?php
/* Connect to an ODBC database using driver invocation */
$serverName = '10.37.129.2';
$databaseName = 'test';
$serverPort = '3306';

$username = 'root';
$password = 'thisismymysql1';

if (class_exists('PDO')) {
    echo "pdo";

    try {
        new PDO("mysql:host=" . $serverName . ";dbname=" . $databaseName . ";port=" . $serverPort, $username, $password);
    } catch (PDOException $e) {
        echo 'Connection failed: ' . $e->getMessage();
    }
};

?>

相关文章

网友评论

      本文标题:SQLSTATE[HY000] [2002] Connectio

      本文链接:https://www.haomeiwen.com/subject/htzlnxtx.html