溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

關(guān)于innodb_data_file_path設(shè)置

發(fā)布時(shí)間:2020-04-25 02:35:10 來(lái)源:網(wǎng)絡(luò) 閱讀:1549 作者:xiaocao13140 欄目:MySQL數(shù)據(jù)庫(kù)
關(guān)于innodb_data_file_path設(shè)置

啟動(dòng)Mysql時(shí)報(bào)錯(cuò),無(wú)法正常啟動(dòng),通過(guò)日志發(fā)有數(shù)據(jù)文件大小錯(cuò)誤,日志如下截圖:

[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!

說(shuō)明:

 innodb_data_file_path用來(lái)指定innodb tablespace文件,如果我們不在My.cnf文件中指定innodb_data_home_dir和innodb_data_file_path那么默認(rèn)會(huì)在datadir目錄下創(chuàng)建ibdata1 作為innodb tablespace。5.6.6之后 兩個(gè)參數(shù)的默認(rèn)值如下:

show variables like 'innodb_data%';


  1. +-----------------------+------------------------+  

  2. | Variable_name         | Value                  |  

  3. +-----------------------+------------------------+  

  4. | innodb_data_file_path | ibdata1:12M:autoextend |  

  5. | innodb_data_home_dir  |                        | >>note:雖然不指定innodb_data_home_dir和指定它為空顯示是一樣的,但是作用確不一樣,如果不指定那么所有的innodb tablespace 文件只能存放在datadir目錄下。如果顯示指定為空,則可以為innodb tablespace 文件指定不同的路徑  


自mysql 5.6.6開(kāi)始我們可以指定多個(gè)innodb tablespace 文件(這些文件可以在相同的路徑下,也可以在不同的路徑下)。但是在為innodb_data_file_path 指定多個(gè)文件時(shí)還是有許多注意事項(xiàng)的,下面我來(lái)看一下
1. 在同一個(gè)路徑下指定多個(gè)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:因?yàn)闆](méi)有指定innodb_data_home_dir,所以ibdata1和ibdata2都在datadir(innodb_data_home_dir默認(rèn)值為datadir)目錄下創(chuàng)建


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 =。這個(gè)例子中會(huì)在datadir下建立ibdata1,在/data/mysql/mysql3306/data1/目錄下創(chuàng)建ibdata2

  如果我不指定innodb_data_home_dir =,只在my.cnf文件中做如下指定:

innodb_data_file_path = ibdata1:12M;/data/mysql/mysql3306/data1/ibdata2:12M:autoextend

然后使用該my.cnf文件進(jìn)行數(shù)據(jù)庫(kù)初始化的時(shí)候,會(huì)發(fā)現(xiàn)初始化失敗,報(bào)錯(cuò)如下:


  1. 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

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI