更改MySQL中的max_heap_table_size值?

max_heap_table_size是同时具有读/写属性的系统变量。

最初,max_heap_table_size的大小为16 MB。首先,检查max_heap_table_size的值(以字节为单位)。

查询如下-

mysql> select @@max_heap_table_size;

以下是输出-

+-----------------------+
| @@max_heap_table_size |
+-----------------------+
| 16777216              |
+-----------------------+
1 row in set (0.00 sec)

现在让我们如何将值16777216字节= 16 MB-

1 MB = 1024KB
1KB = 1024 Bytes
1MB = 1024*1024 bytes.
To convert 16777216 byte to MB you need to divide 1024*1024.
=16777216/(1024*1024)
=16777216/1048576
=16 MB

现在,您可以使用SET命令更改max_heap_table_size。语法如下-

SET @@@@max_heap_table_size=yourNumberOfBytes.

让我们更改max_heap_table_size的值。字节数为33554432,等于32 MB。

查询如下-

mysql> set @@max_heap_table_size=33554432;

现在检查@@ max_heap_table_size的值。查询如下-

mysql> select @@max_heap_table_size;

以下是输出-

+-----------------------+
| @@max_heap_table_size |
+-----------------------+
| 33554432              |
+-----------------------+
1 row in set (0.00 sec)

让我们看看它是否等于32MB。上面讨论了这里使用的公式-

mysql> select @@max_heap_table_size/1048576 as MB;

以下是输出-

+---------+
| MB      |
+---------+
| 32.0000 |
+---------+
1 row in set (0.00 sec)