php mysqli 不能连接mysql.sock
Message: mysqli_connect(): (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
我在命令行 mysql -uroot -p -S/var/lib/mysql/mysql.sock 是可以连上的
TSUMI-
9 years, 3 months ago
Answers
// By UNIX Domain Socket
$mysqli = @new mysqli(
null,
$app['db_username'],
$app['db_password'],
$app['db_name'],
null,
$app['db_socket']
);
// By TCP Port
$mysqli = @new mysqli(
$app['db_host'],
$app['db_username'],
$app['db_password'],
$app['db_name'],
$app['db_port']
);
丨ˉ夜丶未止
answered 9 years, 3 months ago