如何检查和设置max_allowed_pa​​cket mysql变量 [英] how to check and set max_allowed_packet mysql variable

查看:82
本文介绍了如何检查和设置max_allowed_pa​​cket mysql变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
MySQL错误1153-数据包更大比"max_allowed_pa​​cket"字节

Possible Duplicate:
MySQL Error 1153 - Got a packet bigger than ‘max_allowed_packet’ bytes

我收到了错误消息:

[1153] Got a packet bigger than 'max_allowed_packet'bytes

但是我没有对源代码进行任何更改,托管表明他们对服务器设置没有进行任何更改.

but I made no changes in my source code and the hosting states that they did not made any change in server settings.

我不知道发生了什么.但是我正在寻找原因.

I don't know what happened. But I am trying to find the reason.

那么,如何通过php脚本检查max_allowed_packet mysql变量?

so, how to check max_allowed_packet mysql variable by php script?

并且可以在源代码中进行设置吗?

and is that possible to set it in source code?

推荐答案

max_allowed_packet 是在mysql配置中设置的,而不是在php端设置的

max_allowed_packet is set in mysql config, not on php side

[mysqld]
max_allowed_packet=16M 

您可以在mysql中看到它的当前值,如下所示:

You can see it's curent value in mysql like this:

SHOW VARIABLES LIKE 'max_allowed_packet';

您可以尝试像这样更改它,但是不太可能在共享主机上起作用:

You can try to change it like this, but it's unlikely this will work on shared hosting:

SET GLOBAL max_allowed_packet=16777216;

您可以在此处 http://上进行阅读. dev.mysql.com/doc/refman/5.1/en/packet-too-large.html

编辑

至少从mysql 5.5版本开始,[mysqld]是使max_allowed_packet正常运行所必需的.

The [mysqld] is necessary to make the max_allowed_packet working since at least mysql version 5.5.

最近在AWS EC2上使用Drupal和Solr搜索引擎设置了一个实例,该实例需要32M max_allowed_packet.您在/etc/my.cnf中的[mysqld_safe](这是mysql安装随附的默认设置)模式下设置值,则没有任何效果.我没有深入探讨这个问题.但是在将其更改为[mysqld]并重新启动mysqld之后,它就可以了.

Recently setup an instance on AWS EC2 with Drupal and Solr Search Engine, which required 32M max_allowed_packet. It you set the value under [mysqld_safe] (which is default settings came with the mysql installation) mode in /etc/my.cnf, it did no work. I did not dig into the problem. But after I change it to [mysqld] and restarted the mysqld, it worked.

这篇关于如何检查和设置max_allowed_pa​​cket mysql变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆