2016-12-08 54 views
0

我使用MySQL 5.7和CentOS 7.2。MySQL 5.7更改datadir

首先,在我的my.cnf配置的datadir是/ var/lib中/ MySQL的

現在我想改變的datadir。

我哈瓦嘗試兩種方式:

首先,我在/ var/lib中/ MySQL的複製所有文件和目錄到/ home /數據,並運行chown -R mysql:mysql /home/data。但是,當我運行systemctl start mysqld,我收到錯誤消息:

2016-12-08T16:33:38.206780Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable 
2016-12-08T16:33:38.206806Z 0 [ERROR] InnoDB: The innodb_system data file 'ibdata1' must be writable 
2016-12-08T16:33:38.206817Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 
2016-12-08T16:33:38.807398Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 
2016-12-08T16:33:38.807421Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
2016-12-08T16:33:38.807429Z 0 [ERROR] Failed to initialize plugins. 
2016-12-08T16:33:38.807436Z 0 [ERROR] Aborting 

其次,我謹在/ var/lib中/ MySQL的到/ home和運行在/ var/lib目錄ln -s /home/mysql mysql。當我運行systemctl start mysqld,我收到錯誤消息:

2016-12-08T16:48:28.958136Z 0 [ERROR] InnoDB: Operating system error number 13 in a file operation. 
2016-12-08T16:48:28.958165Z 0 [ERROR] InnoDB: The error means mysqld does not have the access rights to the directory. 
2016-12-08T16:48:28.958174Z 0 [ERROR] InnoDB: os_file_get_status() failed on './ibdata1'. Can't determine file permissions 
2016-12-08T16:48:28.958184Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error 
2016-12-08T16:48:29.558751Z 0 [ERROR] Plugin 'InnoDB' init function returned error. 
2016-12-08T16:48:29.558792Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 
2016-12-08T16:48:29.558806Z 0 [ERROR] Failed to initialize plugins. 
2016-12-08T16:48:29.558817Z 0 [ERROR] Aborting 

我該如何處理呢?

+0

我在Windows中有這個問題。一旦我刪除了日誌文件,服務就開始正常運行。 ibdata1將成爲日誌文件,如果你有備份刪除它並嘗試再次啓動服務 – Rajesh

+0

@Rajesh我試圖刪除所有'ib_logfile'。但它不起作用。非常感謝。 – lbear

+0

@ibear你能解決這個問題嗎? –

回答