Linux 中文件和文件夾獲取 MySQL 權限(SELinux)


 

今天在 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM