【问题标题】:Error 'Packet for query is too large' when I tried to make a query on my website当我尝试在我的网站上进行查询时出现错误“查询数据包太大”
【发布时间】:2018-04-24 06:08:06
【问题描述】:

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

我用什么:

  • MySQL 服务器:命令行 mysql -V,结果:mysql Ver 15.1 Distrib 10.1.23-MariaDB,使用 readline 5.2 的 debian-linux-gnu (x86_64)
  • 卡宴
  • Debian 服务器
  • Java (Vaadin)

查询数据包过大 (4739923 > 1048576)。你可以改变这个 通过设置 max_allowed_pa​​cket' 变量在服务器上获取值。

我尝试了什么:

1. 就像错误所说的那样,我尝试通过以下方式更改服务器上的值:

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

但我仍然有错误。

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'文件夹中的文件夹/文件是:

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

编辑:在/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)

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

感谢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" />

【问题讨论】:

    标签: java-8 mariadb apache-cayenne max-allowed-packet


    【解决方案1】:

    改成my.cnf,然后重启mysqld。

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

    [mysqld]
    max_allowed_packet = 1073741824
    

    当您重新启动时,您所做的 (SET) 消失了。尽管如此,它只适用于在执行SET之后登录的连接。

    【讨论】:

    • 嗨@Rick James,感谢您的帮助。但是,我想我按照你说的做了。在您的第一点中:'在my.cnf 中更改它,我尝试过,但就像我说的,我没有任何 [mysqld],我将您在my.cnf 中写的相同行放入并重新启动它:没有成功。然后,您说,将文件放在/ect/mysql/mariadb.conf.d 下,就像我在帖子中所说的那样,我编辑50-server.cnf。我应该创建一个新文件吗?如果是,文件名应该是什么?谢谢
    • 假设...d 是一个目录,创建您喜欢的任何文件名(我使用我的首字母+.cnf)并将这两行放入其中。 50-server.cnf 应该没问题。
    • 不工作:(。当我把它放在一个新的bob.cnf中时,我没有任何变化(我仍然有错误)。这很奇怪,不是吗?
    • 我用屏幕截图更新了帖子(见EDIT1和EDIT2),如你所见,我有你的max_allowed_pa​​cket,它是持久的,当我重新启动mysql时,max_allowed_pa​​cket是一样的......但我仍然有问题...
    • 我检查了:mariadb.com/kb/en/library/server-system-variables/…,我的版本是:10.1.23-MariaDB。当我阅读文档时,'1048576 (1MB)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-28
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    • 2022-01-06
    • 2010-10-31
    相关资源
    最近更新 更多