PDO::__construct(): 发送 108 字节失败,errno=32 Broken pipe

Posted

技术标签:

【中文标题】PDO::__construct(): 发送 108 字节失败,errno=32 Broken pipe【英文标题】:PDO::__construct(): send of 108 bytes failed with errno=32 Broken pipe 【发布时间】:2015-05-24 00:47:15 【问题描述】:

当我登录到我的命令行 mysql 时,我无法再访问任何需要数据库连接的 php 应用程序。每次都会发生这种情况。在我的本地主机上导致问题的步骤:

Command line:
mysql -u root (no password for localhost)
mysql> 

此时我不执行或做任何事情。我使用 root 加载任何需要数据库连接的页面:

PDO::__construct(): send of 108 bytes failed with errno=32 Broken pipe

如果我退出 mysql,页面会返回,但在尝试同时加载两个页面(在浏览器选项卡中)时会出现另一个问题,这将导致其中一个页面中断,直到页面加载,然后我可以刷新

My.cnf:

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

wait_timeout=5000
max_allowed_packet=100m
max_user_connections=1000

【问题讨论】:

更新设置后是否重启了mysql? 你的连接字符串有什么特殊的编码吗?你的mysql默认字符集是什么? 我也不知道这是否会有所不同,但您可能希望在max_allowed_packet 上使用大写字母M 我已经重启了。自从我在 OSX 上安装 mysql 以来,它似乎一直在发生。我检查了我的字符集,它说的是 latin1。不确定这是否是它的假设? 我在 mac 上遇到了同样的错误。有什么解决办法吗? 【参考方案1】:

在你的 MySQL my.cnf 配置文件中设置wait_timeout

wait_timeout=3600

此配置文件位于 /etc/mysql/my.cnf (Ubuntu/Debian) 和 /usr/local/mysql/my.cnf (OSX) 和 /location of server bin folder/mysql/my.cnf 对于 windows。

重新启动 MySQL 服务器并检查它应该可以工作。

【讨论】:

以上是关于PDO::__construct(): 发送 108 字节失败,errno=32 Broken pipe的主要内容,如果未能解决你的问题,请参考以下文章

PDO::__construct():服务器向客户端发送未知字符集 (255)。请向开发人员报告

警告:PDO::__construct(): [2002] 没有这样的文件或目录(试图通过 unix:///tmp/mysql.sock 连接)

PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename or servname provided, or

PDOException::("PDO::__construct(): 使用 MySQL 8 / PHP 7.2 / Laravel 进行缓存_sha2 auth: 109 时出现意外的服务

PDO连接mysql8.0报PDO::__construct(): Server sent charset (255) unknown to the client. Please, report to

[PDOException] PDO::__construct(): php_network_getaddresses: getaddrinfo failed: