Packet for query to large. Setting max_allowed_packet

我与影子孤独终老i 提交于 2020-04-07 08:08:08

问题


When i connect to my databse via phpmyadmin everything works fine and it shows me the data. When i am on my server i can see all data and work with it.

But when i try to connect to my server i'm getting this error:

com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (4.739.923 > 65.535). You can change this value on the server by setting the 'max_allowed_packet' variable.

im getting the max allowed packet size here:


Database changed
MariaDB [selforder]> SELECT @@max_allowed_packet;
+----------------------+
| @@max_allowed_packet |
+----------------------+
|            536870912 |
+----------------------+
1 row in set (0.00 sec)

and i changed my file nano /root/.my.cnf to this:

[mysqld]
max_allowed_packet=536870912

but i still get this error;


回答1:


You changed the max_allowed_packet option in your MariaDB Server, but not for the client.

The client — that is, the JDBC driver in your case — also has a property for the max allowed packet. The actual limit on packet size is the lesser of the client's packet size limit and the MariaDB Server's packet size limit.

To change the client's property, use the configuration property maxAllowedPacket in the JDBC URL.

   jdbc:mysql://dbhost/mydatabase?maxAllowedPacket=536870912


来源:https://stackoverflow.com/questions/61028009/packet-for-query-to-large-setting-max-allowed-packet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!