max_allowed_pa​​cket和文件上传问题

时间:2017-03-17 07:10:43

标签: php mysql wordpress

我不得不从备份恢复我的单词新闻网站。在备份之前,我能够从这个页面上传就好了。从备份恢复后,当我尝试上传文件时,我现在收到以下错误。我上传的文件只有1242KB:

2017-03-16T23:35:14-07:00 Server [Thu Mar 16 23:35:14 2017] [error] [client 00.000.000.00] FastCGI: server "/php56-fpm-handler" stderr: PHP message: WordPress database error Got a packet bigger than 'max_allowed_packet' bytes for query INSERT INTO `wp_cartpauj_pm_attachments` (`message_id`, `filename`, `mimetype`, `contents`) VALUES (777, 'TestFile.pdf', 'application/pdf', '%PDF-1.5\\r\\n%\xb5\xb5\xb5\xb5\\r\\n1 0 obj\\r\\n<</Type/Catalog/Pages 2 0 R/Lang(en-US) >>\\r\\nendobj\\r\\n2 0 obj\\r\\n<</Type/Pages/Count 2/Kids[ 3 0 R 48 0 R] >>\\r\\nendobj\\r\\n3 0 obj\\r\\n<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R/F2 7 0 R/F3 9 0 R/F4 14 0 R/F5 16 0 R/F6 18 0 R/F7 23 0 R/F8 25 0 R/F9 30 0 R/F10 32 0 R/F11 34 0 R/F12 36 0 R/F13 41 0 R/F14 43 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 612 792] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S>>\\r\\nendobj\\r\\n4 0 obj\\r\\n<</Filter/FlateDecode/Length 7511>>\\r\\nstream\\r\\nx\x9c\xbd=ks\xdc\xb8\x91\\\xdf]\\\xe5\xff0\\\xdfnf\\\xcb\\\xc3\\0$\xc1\\\xc7\xd6\x96\xaedYJ6\xb7\\\xc9&\xbb\xce\xa5\xae\x9c\xfb0\x968\x96c{\xa4p\xa4\\\xd5\xf9\xfe\\\xd1\xfd\\\xcb\\\xebn<\b\x90\\0EZ\x84vK\x9e\x19\x12@\x03\xdd\x8d~\xa1\x01\xbc~\xfb\\\xf2\\\xc5\\\xef.\xf8\x8a\\\xf3\x84\xe5\xab\xb7\xfb\x97/\xf8\x8a\xc1\xff\\\xf0$\x15\x89(Wy\x99\x94\\\xc5\\\xea\xed\x97\x97/\\\xd8\\\xea\x03\xfe\\\xf3\xfb\x97/\xde\xad\\\xcf6\\\xdbz}\xb3\x11\\\xeb\\\xdbM\xb6\xfe\xba\\\xd9f\\\xeb\\\xf6\\\xe3\x86..., referer: https://www.example.com/wordpress/private-messaging/?pmaction=newmessage&to=148
2017-03-16T23:35:14-07:00 Server [Thu Mar 16 23:35:14 2017] [warn] [client 00.000.000.00] FastCGI: too much stderr received from server "/php56-fpm-handler", increase FCGI_SERVER_MAX_STDERR_LINE_LEN (1023) and rebuild or use "\\n" to terminate lines, referer: https://www.example.com/wordpress/private-messaging/?pmaction=newmessage&to=148

我的第一个想法是检查我的php设置,但对我来说(max_allowed_packet=32M)看起来都很好。在php.ini我有以下内容:

[PHP]
engine = On
short_open_tag = On
asp_tags = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
serialize_precision = 17
disable_functions =
disable_classes =
zend.enable_gc = On
expose_php = Off
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1024M
error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = Off
variables_order = "GPCS"
request_order = "GP"
register_argc_argv = On
auto_globals_jit = On
post_max_size = 750M
default_mimetype = "text/html"
default_charset = "UTF-8"
include_path = "."
extension_dir = "/usr/local/lib/php56/modules"
sys_temp_dir = "/var/services/tmp"
enable_dl = Off
file_uploads = On
upload_tmp_dir = "/var/services/tmp"
upload_max_filesize = 750M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
max_input_vars = 5000
display_errors = Off
register_globals = Off

[mysqld]
max_allowed_packet=32M

[mysqld_safe] 
ulimit -d 256000 

[CLI Server]
cli_server.color = On

[Date]
date.timezone = Canada/Pacific

[Phar]
phar.readonly = Off

[mail function]
sendmail_path = /usr/bin/ssmtp -t
mail.add_x_header = On

[SQL]
sql.safe_mode = Off

[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1

[PostgreSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0

[bcmath]
bcmath.scale = 0

[Session]
session.save_handler = files
session.save_path = "/var/services/tmp"
session.use_cookies = 1
session.use_only_cookies = 0
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 14400
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check =
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
session.upload_progress.enabled = On
session.upload_progress.cleanup = On
session.upload_progress.prefix = "upload_progress_"
session.upload_progress.name = "PHP_SESSION_UPLOAD_PROGRESS"
session.upload_progress.freq = "1%"
session.upload_progress.min_freq = "1"

[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
mssql.secure_connection = Off

[Tidy]
tidy.clean_output = Off

[soap]
soap.wsdl_cache_enabled = 1
soap.wsdl_cache_dir = "/var/services/tmp"
soap.wsdl_cache_ttl = 86400
soap.wsdl_cache_limit = 5

[ldap]
ldap.max_links = -1

我正在寻找修复此错误所需的操作。任何提示将不胜感激。

1 个答案:

答案 0 :(得分:0)

更改mysqld部分下的my.cnf或my.ini文件并设置:

max_allowed_packet=100M

或者您可以在连接到同一服务器的MySQL控制台中运行这些命令:

set global net_buffer_length=1000000; 
set global max_allowed_packet=1000000000;

对于客户端,您可以在命令行中指定它:

mysql --max_allowed_packet=100M -u root -p database < dump.sql