当我尝试在网站上进行查询时出现“查询数据包太大”错误

Bob*_*Bob 1 mariadb apache-cayenne java-8 max-allowed-packet

我再次需要你的帮助。我正在尝试将我的 java 网站上线。

我用什么:

  • MySQL 服务器:命令行 mysql -V,结果:mysql Ver 15.1 Distrib 10.1.23-MariaDB,对于 debian-linux-gnu (x86_64) 使用 readline 5.2
  • 辣椒
  • Debian服务器
  • 爪哇(瓦丁)

用于查询的数据包太大 (4739923 > 1048576)。您可以通过设置 max_allowed_pa​​cket' 变量在服务器上更改此值。

我尝试过的:

1.就像错误所说的那样,我尝试通过执行以下操作来更改服务器上的值:

  • 登录我的服务器
  • 使用以下命令连接到 MySQL:mysql -u root
  • 进入 :SET GLOBAL max_allowed_packet=1073741824;
  • 然后,使用以下命令重新启动服务器:/etc/init.d/mysql restart

但我仍然有错误。

2.我查看了:如何更改 max_allowed_pa​​cket 大小

但是,当我执行此操作时nano /etc/mysql/my.cnf,文件看起来像(我没有任何 [mysql]):

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Nov 10 23:57:02 2017 from 82.236.220.195
root@XXXX:~# nano /etc/mysql/my.cnf
  GNU nano 2.7.4               File: /etc/mysql/my.cnf                Modified

# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
# The MariaDB configuration file
#
# The MariaDB/MySQL tools read configuration files in the following order:
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
# 4. "~/.my.cnf" to set user-specific options.
#
# If the same option is defined multiple times, the last one will apply.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

# Import all .cnf files from configuration directory
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mariadb.conf.d/
Run Code Online (Sandbox Code Playgroud)

在 mysql 中,“mysql”文件夹中的文件夹/文件是:

在此输入图像描述

任何提示将非常感激!谢谢

编辑:/etc/mysql/mariadb.conf.d/50-server.cnf,我改变了:

  1. max_allowed_packet = 1073741824
  2. max_connections = 100000

我补充道:net_buffer_length = 1048576

有关信息:在我的工作台中,我可以看到服务器变量: 在此输入图像描述

EDIT2:现在,当我在服务器上的命令行中选择变量时,我有:

MariaDB [(none)]> SELECT @@global.max_allowed_packet;
+-----------------------------+
| @@global.max_allowed_packet |
+-----------------------------+
|                  1073741824 |
+-----------------------------+
1 row in set (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

解决方案因为错误不明确。

感谢com.mysql.jdbc.PacketTooBigException

我的辣椒配置是:

<url value="jdbc:mysql://IPADDRESS:22/DBBASENAME" />
<login userName="ServerUserName" password="ServerPassword" />
Run Code Online (Sandbox Code Playgroud)

但它应该是:

<url value="jdbc:mysql://IPADDRESS/DBBASENAME" />
<login userName="MYSQLUserName" password="MYSQLPassword" />
Run Code Online (Sandbox Code Playgroud)

Ric*_*mes 6

更改它my.cnf,然后重新启动 mysqld。

更好的是,将其放入 下的文件中/etc/mysql/mariadb.conf.d/,并指定该部分:

[mysqld]
max_allowed_packet = 1073741824
Run Code Online (Sandbox Code Playgroud)

重新启动后,您所做的 ( SET) 操作就会消失。即便如此,它仅适用于执行SET.