在本地上运行好好,然后发布到服务器上去, 总是报错,后来查了一下日志,得到了如下的错误日志:
[org.hibernate.engine.jdbc.spi.SqlExceptionHelper] Packet for query is too large (1079 > 1024). You can change this value on the server by setting the max_allowed_packet' variable. [n/a]
com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1079 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3248)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1940)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2275)
解决
MySQL配置文件在Windows下叫my.ini,在MySQL的安装根目录下;在Linux下叫my.cnf,该文件位于/etc/my.cnf。
找到这个配置文件,
vim /etc/my.cnf
在里面加入一行 或 修改这行的值:
[mysqldump]
max_allowed_packet = 32M
这个值主要视个人的情况而定, 我这原来的值为 16M , 还是不够, 加大了一倍. 暂时设置为 32M,
重启mysql,就可以解决了.
=====================
附linux 重启 mysql 命令:
1.启动:/etc/init.d/mysql start
2.停止:/etc/init.d/mysql stop
3.重启:/etc/init.d/mysql restart