Linux 中檔案和檔案夾擷取 MySQL 許可權(SELinux)

來源:互聯網
上載者:User

今天在 Linux 系統上移動 MySQL 的資料庫目錄

配置如下:

/etc/my.cnf

[mysqld]
datadir=/home/mysql
socket=/var/lib/mysql/mysql.sock

更改完設定檔重啟MYSQL的時候出現的以下問題

110222 11:15:07 mysqld_safe Starting mysqld daemon with databases from /home/mysql
110222 11:15:07 [Warning] Can't create test file /home/mysql/localhost.lower-test
110222 11:15:07 [Warning] Can't create test file /home/mysql/localhost.lower-test
 /usr/libexec/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
110222 11:15:07 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110222 11:15:07  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
110222 11:15:07 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

當初以為只是檔案或檔案夾許可權問題,把所有對應的目錄和檔案的許可權改成讀寫狀態...還是沒用...

在網上找了一會兒,找到解決方案了~

解決方案如下:

#在終端中先輸入下面這一行

chown -R mysql:mysql /home/data/mysql
#在輸入下面的一行就OK了

chcon -R -t mysqld_db_t /home/mysql

#重啟下MYSQL試試~

/etc/init.d/mysqld restart

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.