gpt4 book ai didi

php - 问题 : PHP Fatal error: Can't connect to local MySQL server through socket

转载 作者:行者123 更新时间:2023-11-30 23:39:34 27 4
gpt4 key购买 nike

我在运行我的 php 代码时遇到问题(有时它会成功运行,但我需要在未来如何避免它)错误显示为:

PHP Fatal error:  Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/myegyme/public_html/Connections/myegy.php on line 9

和“/home/myegyme/public_html/Connections/myegy.php”包含:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_myegy = "localhost";
$database_myegy = "mydatabase";
$username_myegy = "myusername";
$password_myegy = "mypassword";
$myegy = mysql_pconnect($hostname_myegy, $username_myegy, $password_myegy) or trigger_error(mysql_error(),E_USER_ERROR);
?>

我该如何解决这个问题?。请帮助我!

最佳答案

添加

[client]
socket=/var/lib/mysql/mysql.sock

my.cnf,如上所述

http://www.tech-recipes.com/rx/762/solve-cant-connect-to-local-mysql-server-through-socket-tmpmysqlsock/

关于php - 问题 : PHP Fatal error: Can't connect to local MySQL server through socket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4627544/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com