Linux

將 MySQL 數據目錄移動到新驅動器時出現問題

  • September 18, 2013

我有一個 EC2 實例,正在嘗試將 mysql 數據目錄從預設驅動器移動到另一個 EBS 卷。我將 mysql 目錄移動/var/lib/mysql到新的目的地,然後修改my.cnf文件以將數據目錄指向新位置。然後我嘗試重新啟動 mysql 我收到以下消息。

MySQL Daemon failed to start.
Starting mysqld:                                           [FAILED]

我正在執行一個新的 EC2 實例附帶的預設 Linux 發行版。以下是my.cnf文件的詳細資訊和mysqld.log. 關於我可能做錯了什麼的任何建議?

我的.cnf

[mysqld]
#datadir=/var/lib/mysql
datadir=/root/appfinder/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

設置文件夾權限

chmod -R 777 /root/appfinder/mysql

mysqld.log

110616 18:37:53 mysqld_safe Starting mysqld daemon with databases from /root/appfinder/mysql
/usr/libexec/mysqld: Table 'plugin' is read only
110616 18:37:53 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: Log scan progressed past the checkpoint lsn 0 37356   
110616 18:37:53  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...  
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 0 44233
110616 18:37:53  InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percents: 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66$
InnoDB: Apply batch completed
110616 18:37:53  InnoDB: Started; log sequence number 0 44233
5110616 18:37:53 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'host' is read only
110616 18:37:53 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

我嘗試將我的 EBS 卷重新掛載到/myFolder而不是/root/myFolder. 這似乎已經糾正了權限問題。

/root/appfinder/mysql 目錄必須是所有者 mysql。為此,chown mysql:mysql /root/appfinder/mysql 和 chown -R mysql:mysql /root/appfinder/mysql/。

mysql的所有數據文件必須是所有者mysql。

引用自:https://serverfault.com/questions/281217