如何在MySQL中修改innodb_data_file_path参数事项

  介绍

如何在MySQL中修改innodb_data_file_path参数事项?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

在测试环境下没有设置过多的详细参数就初始化并启动了服务,后期优化的过程中发现innodb_data_file_path设置过小:

root@node1  14:59:,[(一)]祝辞,show  variables  like  & # 39; % innodb_data_file_path % & # 39;;   + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - +   | |,Variable_name  Value  |   + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - +   | |,innodb_data_file_path  ibdata1:12M: autoextend  |   + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - +   1,row  set 拷贝;(0.00,sec)      root@node1  14:59:[(一)]在

当没有配置innodb_data_file_path时,默认<代码> innodb_data_file_path=ibdata1:12M: autoextend

(mysqld)   时间=innodb_data_file_path  ibdata1:12M: autoextend

当需要改为1 g时,不能直接在配置文件把ibdata1改为1 g,

(mysqld)   innodb_data_file_path =, ibdata1:1G: autoextend

否则启动服务之后,从错误日志看到如下报错:

2019 - 03 - 29 t06:47:32.044316z 0(错误)InnoDB:的Auto-extending innodb_system数据文件& # 39;。/ibdata1& # 39;不同大小的768页(四舍五入MB)比在.cnf文件中指定:最初的65536页,马克斯0(如果零相关)页面!

大致意思就是ibdata1的大小不是<代码> 65536 * 16 kb/1024 kb页=1 g> 786页* 16 kb/1024 kb=12 m
(未使用压缩页)

<强>方法一:推荐

而应该再添加一个ibdata2:1G,如下:

(mysqld)   innodb_data_file_path =, ibdata1:12M; ibdata2:1G: autoextend

重启数据库!

<强>方法二:不推荐

直接改为如下的话

(mysqld)   innodb_data_file_path =, ibdata1:1G: autoextend

可以删除美元mysql_datadir目录下ibdata1, ib_logfile0, ib_logfile1文件:

rm  -f  ibdata *, ib_logfile *

也可以启动MySQL,但是MySQL错误日志里会报如下错误:

2019 - 03 - 29 t07:10:47.844560z  0,[警告],Could  not  increase  number  of  max_open_files 用more  than  5000年,(要求:,65535)   2019 - 03 - 29 t07:10:47.844686z  0,[警告],Changed 限制:,table_open_cache:, 1983, (requested  2000)   2019 - 03 - 29 t07:10:48.028262z  0,[警告],& # 39;NO_AUTO_CREATE_USER& # 39;, sql  mode  was  not 集。   2019 - 03 - 29 t07:10:48.147653z  0,[警告],InnoDB:, Cannot  open  table  mysql/plugin 得到,internal  data  dictionary  of  InnoDB  though 从而.frm  file  for 从而table 存在只Please  refer 用http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html  for 请;用resolve 从而问题。   mysqld: Table  & # 39; mysql.plugin& # 39;,并# 39;t 存在   2019 - 03 - 29 t07:10:48.147775z  0,(错误),停下来# 39;t  open 从而mysql.plugin 表只Please  run  mysql_upgrade 用create 它。   2019 - 03 - 29 t07:10:48.163444z  0,[警告],InnoDB:, Cannot  open  table  mysql/gtid_executed 得到,internal  data  dictionary  of  InnoDB  though 从而.frm  file  for 从而table 存在只Please  refer 用http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html  for 请;用resolve 从而问题。   mysqld: Table  & # 39; mysql.gtid_executed& # 39;,并# 39;t 存在   2019 - 03 - 29 t07:10:48.163502z  0,[警告],Gtid  table  is  not  ready 用be 使用只table  & # 39; mysql.gtid_executed& # 39; cannot  be 打开。   2019 - 03 - 29 t07:10:48.163658z  0,[警告],InnoDB:, Cannot  open  table  mysql/gtid_executed 得到,internal  data  dictionary  of  InnoDB  though 从而.frm  file  for 从而table 存在只Please  refer 用http://dev.mysql.com/doc/refman/5.7/en/innodb-troubleshooting.html  for 请;用resolve 从而问题。   mysqld: Table  & # 39; mysql.gtid_executed& # 39;,并# 39;t 存在   2019 - 03 - 29 t07:10:48.163711z  0,[警告],Gtid  table  is  not  ready 用be 使用只table  & # 39; mysql.gtid_executed& # 39; cannot  be 打开。   2019 - 03 - 29 t07:10:48.164619z  0,[警告],Failed 用set  up  SSL  because  of 从而following  SSL  library 错误:,SSL  context  is  not  usable  without  certificate 以及private 关键   null   null   null   null   null   null   null   null   null   null   null   null   null   null

如何在MySQL中修改innodb_data_file_path参数事项