- 目的:mysql根據配置文件會限制server接受的數據包大小。有時候大的插入和更新會被max_allowed_packet 參數限制掉,導致失敗。
- 環境:ubuntu14.04
mysql> show VARIABLES like '%max_allowed_packet%';
顯示結果:+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_allowed_packet | 1048576 |
+--------------------+---------+
以上說明目前的配置是:1M
- 編輯mysql.cnf中的[mysqld]段,增加/修改爲:max_allowed_packet = 20M
- 然後,重啓mysql服務,再次進行查看以確認是否設置生效。
p.s.這樣的修改方式不會因爲重啓服務而丟棄設置。
注意:
1.如果找不到mysql.cnf文件,可以在/etc/目錄下查找“mysql*.cnf":
linda@linda-pc:/etc$ find -name "mysql*.cnf"
find: `./docker': Permission denied
find: `./ssl/private': Permission denied
find: `./cups/ssl': Permission denied
find: `./polkit-1/localauthority': Permission denied
find: `./dovecot/private': Permission denied
./mysql/mysql.cnf
./mysql/conf.d/mysql.cnf
./mysql/mysql.conf.d/mysqld.cnf
2.重啓mysql服務:linda@linda-pc:/etc/init.d$ sudo service mysql restart
* Stopping MySQL Community Server 5.7.18
.....
* MySQL Community Server 5.7.18 is stopped
* Re-starting MySQL Community Server 5.7.18
..
* MySQL Community Server 5.7.18 is started