In the MySQL database, a table has a BLOB field, the following error occurs when uploading a file over 1M:
PreparedStatementCallback; SQL [insert INTO Uos.docfile (remark,content,email,addtime,filename) VALUES (' 654645 ',?, ' [e-mail protected] ', now (), ' Fly higher-Wang Feng. mp3 ')]; Packet for query is too large (6571400 > 1048576). You can change this value on the server by setting the Max_allowed_packet ' variable.; Nested exception is com.mysql.jdbc.PacketTooBigException:Packet for query is too large (6571400 > 1048576). You can change this value on the server by setting the Max_allowed_packet ' variable.
The problem is solved as follows.
Open/etc/my.cnf with VI, add the following bold line, this sentence is to change the size of the upload file to 20M:
[Mysqld]datadir=/var/lib/Mysqlsocket=/var/lib/mysql/mysql.sockmax_allowed_packet = 20Muser=mysql# Default to using the old password format forCompatibility with MySQL3. x# clients (those using the Mysqlclient10 compatibility package). Old_passwords=1# Disabling Symbolic-links are recommended to prevent assorted security risks;# to DoSo, uncomment this line:# symbolic-links=0[Mysqld_safe]log-error=/var/log/Mysqld.logpid-file=/var/run/mysqld/mysqld.pid
After the modification, save exit.
Use the command #service mysqld restart
Restart the MySQL service, and then upload the file can not be too large problem solved.
Tuning MySQL database max_allowed_packet in Linux