Change the location of MySQL data files on Linux

Source: Internet
Author: User

With the soft connection changed the location of the/var/lib/mysql, and set the Mysql.mysql permissions, but found still cannot start.

Discover/var/log/mysqld.log

150308 16:16:02 [Warning] Can ' t ' Create test File/var/lib/mysql/gadget.lower-test

150308 16:16:02 [Warning] Can ' t ' Create test File/var/lib/mysql/gadget.lower-test
/usr/libexec/mysqld:can ' t change dir to '/var/lib/mysql/' (errcode:13)

Think that should still be some kind of permission problem, after checking the post found

Chcon-t Var_lib_t/home
Chcon-r-T Mysqld_db_t/home/mysql

Reason is

Look at the first time the properties of the/var/lib/mysql directory:
[Email protected] mysql]# Ls-alz
Drwxr-xr-x. MySQL MySQL system_ubject_r:mysqld_db_t:s0.
Drwxr-xr-x. Root root system_ubject_r:var_lib_t:s0.
-RW-RW----. MySQL MySQL unconfined_ubject_r:mysqld_db_t:s0 centos6-relay-bin.000001
-RW-RW----. MySQL MySQL unconfined_ubject_r:mysqld_db_t:s0 centos6-relay-bin.000002
-RW-RW----. MySQL MySQL unconfined_ubject_r:mysqld_db_t:s0 centos6-relay-bin.index
-RW-RW----. MySQL MySQL unconfined_ubject_r:mysqld_db_t:s0 ibdata1
-RW-RW----. MySQL MySQL unconfined_ubject_r:mysqld_db_t:s0 ib_logfile0
-RW-RW----. MySQL MySQL unconfined_ubject_r:mysqld_db_t:s0 ib_logfile1
-RW-RW----. MySQL MySQL unconfined_ubject_r:mysqld_db_t:s0 master.info
DRWX------. MySQL MySQL unconfined_ubject_r:mysqld_db_t:s0 MySQL
-RW-RW----. MySQL MySQL unconfined_u:object_r:mysqld_db_t:s0 mysqld-relay-bin.000001
-RW-RW----. MySQL MySQL unconfined_u:object_r:mysqld_db_t:s0 mysqld-relay-bin.index
Srwxrwxrwx. MySQL MySQL unconfined_u:object_r:mysqld_var_run_t:s0 mysql.sock
-RW-RW----. MySQL MySQL unconfined_u:object_r:mysqld_db_t:s0 relay-log.info
DRWX------. MySQL MySQL unconfined_u:object_r:mysqld_db_t:s0 test


The SELinux attribute of Discovery/var/lib is var_lib_t
/var/lib/mysql the SELinux attribute for all files below is mysqld_db_t

So these two steps must be executed.

Change the location of MySQL data files on Linux

Related Article

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.