Obtain MySQL permissions for files and folders in Linux (SELinux)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.