zoukankan      html  css  js  c++  java
  • Linux中MySQL数据库max_allowed_packet的调整

    在MySQL数据库里某表有一个blob字段,当上传文件超过1M的时候出现下面的错误:

    PreparedStatementCallback; SQL [insert into uos.docfile(remark,content,email,addtime,filename) values ('654645',?,'ufo@163.com',NOW(),'飞得更高-汪峰.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.

    这个问题是如下解决的。

    用VI打开/etc/my.cnf,增加下面加粗的一行,这句话是把上传文件大小改到20M:

    [mysqld]
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    max_allowed_packet = 20M
    user=mysql
    # Default to using old password format for compatibility with mysql 3.x
    # clients (those using the mysqlclient10 compatibility package).
    old_passwords=1
    
    # Disabling symbolic-links is recommended to prevent assorted security risks;
    # to do so, uncomment this line:
    # symbolic-links=0
    
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid

    修改完毕,保存退出。

    使用命令#service mysqld restart

    重启mysql服务,然后上传文件不能过大的问题就解决了。

  • 相关阅读:
    getter 和 setter方法
    了解coredata 数据库的博客
    iOS 本地缓存简述
    iOS 9.0 xcode7
    iOS 直播推流SDK -- PLCameraStreamingKit
    时间充裕的时候看看技术总结
    技术分享7
    学习笔记-音频编解码
    学习笔记-weak strong ARC mrc
    飘雪效果的swf
  • 原文地址:https://www.cnblogs.com/heyang78/p/4168854.html
Copyright © 2011-2022 走看看