Tuning MySQL database max_allowed_packet in Linux

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.