gpt4 book ai didi

mysql show variables like 'innodb%' 什么都没返回

转载 作者:行者123 更新时间:2023-11-29 01:22:32 24 4
gpt4 key购买 nike

我在 RHEL6.3 上运行 MySQL 服务器 5.1.61。 MysQL 服务器运行正常,但我发现我需要调整 innodb_buffer_pool_size。我认为可以使用

显示此变量

mysql> show variables like 'innodb%';

但实际上,它什么也没有返回。为什么它什么都不返回?我在哪里可以看到实际的 innodb_buffer_pool_size(除了 my.cnf 文件)。

PS:我知道我可以更改my.cnf中的innodb_buffer_pool_size并重启MySQL,但为什么看不到它的实际值?

最佳答案

在 MySQL 5.1 上,如果 InnoDB 存储引擎在启动过程中遇到错误,则可能无法初始化。在那种情况下,它只是禁用 InnoDB 并继续。可以访问 MyISAM 表,但不能访问 InnoDB 表。

检查是否启用了 InnoDB 存储引擎。这是 5.1.65 实例的输出:

mysql> show variables like 'have_innodb';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb | YES |
+---------------+-------+

mysql> show engines;
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+------------+---------+----------------------------------------------------------------+--------------+------+------------+
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
. . .

接下来我模拟了 InnoDB 故障,通过编辑 my.cnf 设置 innodb_log_file_size=256M,这不是磁盘上日志文件的大小。然后我重新启动了实例。

mysql> show variables like 'have_innodb';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| have_innodb | NO |
+---------------+-------+

mysql> show variables like 'innodb%';
Empty set (0.00 sec)

麻烦了!去哪里看?错误日志文件:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
130218 12:50:46 [ERROR] Plugin 'InnoDB' init function returned error.
130218 12:50:46 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

如果 MySQL 在初始化 InnoDB 时遇到错误,您还可以强制 MySQL 中止启动,这样您就再也不会遇到这种情况了。将此添加到/etc/my.cnf:

[mysqld]
innodb=force

然后当我尝试启动时,我在错误日志中看到了这个:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 268435456 bytes!
130218 12:55:03 [ERROR] Plugin 'InnoDB' init function returned error.
130218 12:55:03 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
130218 12:55:03 [ERROR] Failed to initialize plugins.
130218 12:55:03 [ERROR] Aborting

130218 12:55:03 [Note] /home/billkarwin/opt/mysql/5.1.65/bin/mysqld: Shutdown complete

在 MySQL 5.5 中,如果 InnoDB 初始化失败,服务器将不会启动。

关于mysql show variables like 'innodb%' 什么都没返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14943887/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com