使用以下命令来修改变量
set global {要改的key} = {值}; (立即生效重启后失效) set @@{要改的key} = {值}; (立即生效重启后失效) set @@global.{要改的key} = {值}; (立即生效重启后失效)试验
mysql> set @@global.innodb_buffer_pool_size=4294967296; ERROR 1238 (HY000): Variable 'innodb_buffer_pool_size' is a read only variable mysql> set @@global.thread_stack=262144; ERROR 1238 (HY000): Variable 'thread_stack' is a read only variable mysql> set @@global.binlog_cache_size=65536; Query OK, 0 rows affected (0.00 sec) mysql> set @@join_buffer_size=1048576; Query OK, 0 rows affected (0.00 sec) mysql> set @@read_rnd_buffer_size=4194304; Query OK, 0 rows affected (0.00 sec) mysql> set @@sort_buffer_size=262144; Query OK, 0 rows affected (0.00 sec) mysql> set @@read_buffer_size=131072; Query OK, 0 rows affected (0.00 sec) mysql> set global key_buffer_size=8388608; Query OK, 0 rows affected (0.39 sec)我们可以看到innodb_buffer_pool_size和thread_stack报错了,他们只能改配置文件,在运行时是只读的。 以下直接复制使用
set @@global.binlog_cache_size=65536; set @@join_buffer_size=1048576; set @@read_rnd_buffer_size=4194304; set @@sort_buffer_size=262144; set @@read_buffer_size=131072; set global key_buffer_size=8388608; 引用记一次Mysql占用内存过高的优化过程
mysql 优化技巧心得一(key_buffer_size设置)
mysql内存计算
mysql计算器
mariadb官网
此文已由腾讯云+社区在各渠道发布