Move the MySQL database directory on Linux today
The configuration is as follows:
/Etc/my. cnf
[Mysqld]
Datadir =/home/mysql
Socket =/var/lib/mysql. sock
The following problems occur when the configuration file is changed and MYSQL is restarted:
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
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. pid ended
I thought it was just a file or folder permission problem. I changed all the corresponding directory and file permissions to read/write status... it is still useless...
After searching for a while on the internet, I found a solution ~
The solution is as follows:
# Enter the following line in the terminal
Chown-R mysql: mysql/home/data/mysql
# Enter the following line and it will be OK.
Chcon-R-t mysqld_db_t/home/mysql
# Try restarting MYSQL ~
/Etc/init. d/mysqld restart