首页 > 解决方案 > 增加 MySQL 缓冲查询内存限制

问题描述

我在网上找不到答案,所以我碰运气在这里问。

如何增加 MySQL 缓冲查询内存限制?

我尝试使用 PHP 执行 PDO 查询,但出现错误Out of memory (allocated 1444937728)。查了一会儿,发现跟PHP没有关系,跟MySQL的限制有关。

虽然更改mysql配置仍然无法解决错误。这是我的配置

[mysqld]
port = 3306
socket = C:/neard/tmp/mariadb.sock
key_buffer_size = 64M
max_allowed_packet = 64M
bulk_insert_buffer_size = 2048M
table_open_cache = 1000
sort_buffer_size = 64M
read_buffer_size = 64M
read_rnd_buffer_size = 64M
innodb_sort_buffer_size = 32M
myisam_sort_buffer_size = 32M
basedir=C:/neard/bin/mariadb/mariadb10.3.8
log-error=C:/neard/logs/mariadb.log
datadir=C:/neard/bin/mariadb/mariadb10.3.8/data

long_query_time=3
slow_query_log_file=C:/neard/logs/slow_query.log

skip-external-locking

server-id = 1

innodb_buffer_pool_size = 128M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M

显然,这个数字1444937728是在某处定义或计算的,但我找不到有关此的文档。

注意:大多数表引擎是MyISAM

标签: phpmysqlpdoout-of-memory

解决方案


更改 php.ini 中的设置。

部分:sqlsrv

指令:sqlsrv.ClientBufferMaxKBSize。

client_buffer_max_kb_size = '50240'
sqlsrv.ClientBufferMaxKBSize = 50240

推荐阅读