您好,登錄后才能下訂單哦!
啟動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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。