0

我正在使用第 3 方 API 在数据库中插入数据。我已经在我的本地计算机中遇到了这个问题,我将它设置max_allowed_packet为其他帖子所说的,它对我有用。但现在我正在使用我们的 linux 远程服务器来插入数据。我找不到那个my.ini或一些配置文件,但有类似的文件,这里命名50-server.cnf的是它的一些内容

#
# * Fine Tuning
#
key_buffer_size     = 16M
max_allowed_packet  = 1024M
thread_stack        = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam_recover_options  = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10

#
# * Query Cache Configuration
#
query_cache_limit   = 32M
query_cache_size        = 1024M


为了设置全局变量,我还在我们的 linux 远程终端中编写了一堆查询。这是其中的一些

sudo mysql

SET SESSION wait_timeout = 999999;

SET SESSION net_read_timeout = 1000

SET GLOBAL connect_timeout = 1000;

之后我运行 sudo /etc/init.d/mysql restart 然后我执行我的控制器功能但我仍然得到 PDOStatement::execute(): MySQL server has gone away

我在用

mysql: mysql Ver 15.1 Distrib 10.1.43-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Linux: Linux ip-172-31-16-16 4.15.0-1054-aws #56-Ubuntu SMP Thu Nov 7 16:15:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

PHP: Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.11-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

玛丽亚数据库: mariadb Ver 15.1 Distrib 10.1.43-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

有人可以告诉我这有什么问题吗?

4

1 回答 1

0

评论太长了。

  1. 您的设置没有用 - 重新启动后 my.cnf 配置文件中的默认值将被使用。还会SET SESSION更改当前连接的值。

  2. 检查以下事项:

    • 它是服务器错误(例如服务器崩溃)吗?. 出现错误后,通过mysql命令行客户端登录,使用\sorstatus命令查看服务器正常运行时间。

    • 打开 MariaDB 服务器的错误日志文件到最后,检查是否有一些有用的信息。

    • 尝试在 mysql 命令行客户端中执行语句(传递给 PDO::execute)。
    • 如果是 SELECT 语句,请确保结果集的大小不超过max_allowed_packet大小。
    • 使用 tcpdump 捕获流量,使用 wireshark 打开文件,将过滤器设置为mysql并检查是否可以找到更多信息。
于 2020-02-04T10:00:47.847 回答