当我尝试在我的网站上进行查询时出现错误 'Packet for query is too large'

Error 'Packet for query is too large' when I tried to make a query on my website

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

我用的:

Packet for query is too large (4739923 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.

我试过的:

1. 如错误所述,我尝试通过以下方式更改服务器上的值:

但我仍然有错误。

2. 我看了一下:How to change max_allowed_packet size

但是,当我执行 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/

在mysql中,'mysql'文件夹中的folders/files是:

任何提示将不胜感激! 谢谢

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

  1. max_allowed_packet = 1073741824
  2. max_connections = 100000

我补充说:net_buffer_length = 1048576

有关信息: 在我的 workbench 中,我可以看到服务器变量:

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

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

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

感谢com.mysql.jdbc.PacketTooBigException

我的卡宴配置是:

<url value="jdbc:mysql://IPADDRESS:22/DBBASENAME" />
<login userName="ServerUserName" password="ServerPassword" />

但应该是:

<url value="jdbc:mysql://IPADDRESS/DBBASENAME" />
<login userName="MYSQLUserName" password="MYSQLPassword" />

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

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

[mysqld]
max_allowed_packet = 1073741824

您所做的 (SET) 在您重新启动时消失了。即便如此,它仅适用于在执行 SET.

后登录的连接