启动Mysql时报错,无法正常启动,通过日志发有数据文件大小错误,日志如下截图:
[ERROR] InnoDB: auto-extending data file /usr/local/mysql/data/ibdata1 is of a different size 768 pages (rounded down to MB) than specified in the .cnf file: initial 65536 pages, max 0 (relevant if non-zero) pages!
2018-05-25 14:27:04 6002 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
说明:
show variables like 'innodb_data%';
+-----------------------+------------------------+
| Variable_name | Value |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:12M:autoextend |
| innodb_data_home_dir | | >>note:虽然不指定innodb_data_home_dir和指定它为空显示是一样的,但是作用确不一样,如果不指定那么所有的innodb tablespace 文件只能存放在datadir目录下。如果显示指定为空,则可以为innodb tablespace 文件指定不同的路径
自mysql 5.6.6开始我们可以指定多个innodb tablespace 文件(这些文件可以在相同的路径下,也可以在不同的路径下)。但是在为innodb_data_file_path 指定多个文件时还是有许多注意事项的,下面我来看一下
1. 在同一个路径下指定多个innodb tablespace 文件
1)
在my.cnf文件指定如下
[mysqld]
innodb_data_file_path = ibdata1:1G;ibdata2:12M:autoextend:max:500M
note:The autoextend and max attributes can be used only for the last data file in the innodb_data_file_path line.
note:因为没有指定innodb_data_home_dir,所以ibdata1和ibdata2都在datadir(innodb_data_home_dir默认值为datadir)目录下创建
2)
在my.cnf文件指定如下
[mysqld]
innodb_data_home_dir = /data/mysql/mysql3306/data
innodb_data_file_path = ibdata1:1G;ibdata2:12M:autoextend:max:500M
note:可以显示的指定innodb tablespace文件的路径,如果指定innodb_data_home_dir,那么就不能为innodb tablespace不同文件指定不同路径
2. 在不同路径下指定innodb tablespace
在my.cnf文件下指定
[mysqld]
innodb_data_home_dir =
innodb_data_file_path = ibdata1:12M;/data/mysql/mysql3306/data1/ibdata2:12M:autoextend
note:如果想为innodb tablespace指定不同目录下的文件,必须指定innodb_data_home_dir =。这个例子中会在datadir下建立ibdata1,在/data/mysql/mysql3306/data1/目录下创建ibdata2
如果我不指定innodb_data_home_dir =,只在my.cnf文件中做如下指定:
innodb_data_file_path = ibdata1:12M;/data/mysql/mysql3306/data1/ibdata2:12M:autoextend
然后使用该my.cnf文件进行数据库初始化的时候,会发现初始化失败,报错如下:
2016-03-24 16:58:34 29559 [ERROR] InnoDB: File .//data/mysql/mysql3306/data1/ibdata2: 'create' returned OS error 71. Cannot continue operation
##所以如果想为innodb tablespace文件指定不同路径,那么必须在my.cnf文件中指定innodb_data_home_dir =
参考资料:https://blog.csdn.net/shaochenshuo/article/details/50973068
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。