【发布时间】:2017-05-14 21:18:27
【问题描述】:
我在使用 PHP7 脚本将数据保存到数据库 (MariaDB) 时遇到问题。该脚本在以前的托管包上运行良好,但在我的新 VPS 上却不行。
Warning: Error while sending QUERY packet. PID=1208 in ...
其他线程导致我查看设置,但我的设置是:
- max_allowed_packet = 1GB
- wait_timeout = 10
我进一步检查了这个问题,发现查询本身没有问题(它在 phpMyAdmin 中执行良好)。
这似乎与在不关闭连接的情况下连续执行两个查询有关(第二个失败)。
相同的脚本在旧主机上运行良好,它必须是一个设置 - 有人有什么想法吗?
非常感谢, 本
MariaDB 配置(/etc/my.cnf):
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1GB
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
innodb_file_per_table
max_connections=70
max_user_connections=30
wait_timeout=10
interactive_timeout=50
long_query_time=5
【问题讨论】:
-
你已经有了答案
It seems to be something to do with executing two queries in close succession without closing the connection (the second one fails).