Mysql DataPacketTooBigException異常處理

來源:互聯網
上載者:User

標籤:本地   安裝   The   sqlio   var   inter   ber   win   rest   

在本地上運行好好,然後發布到伺服器上去, 總是報錯,後來查了一下日誌,得到了如下的錯誤記錄檔:

[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

 

Mysql DataPacketTooBigException異常處理

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.