MySQL prompt [Warning] cant create test file xxx lower-test

Source: Internet
Author: User


I think you must have come in from the seo/seo.html "target=" _blank > Search engine searching this title! You must be trying to change the MySQL default installed data Directory!
You've modified the value of DataDir in MY.CNF.

First, view the database log

Mysqld started

[Warning] Can ' t create test file Xxx.lower-test
[Warning] Can ' t create test file Xxx.lower-test
/usr/libexec/mysqld:can ' t change dir to '/xxx ' (errcode:13)
[ERROR] Aborting

You've chown and chmod several times. The owner and the permissions of the new data directory or its parent path

You've tried countless times to service MySQL start, or/etc/init.d/mysql start, and mysql_install_db!

Congratulations on seeing this article, I found a way to solve it after a few hours of being in the system pit.

There are two reasons for this, and any one of them can cause you to be told the warning by the system. If you're not a professional Linux system security engineer, or you're just a PHP programmer, and you don't have in-depth research into system security, it's not easy to find the answer.

First, SELinux, remember when studying, the character interface installation Redhat (very old operating system mody ...) When there is such an option, usually everyone listens to seniors ' suggestions to change the default value to not install it. But if the machine you're working on is selinux, it does make it impossible for your MySQL to mysql_install_db in the new target location and burst the warning in the title. A simple solution is to use the command to temporarily close SELinux so that your operation can continue.
Setenforce 0

However, it is a good idea to use a permanent method to continue to avoid the product after restarting.

Modify the/etc/selinux/config file to set the selinux=disabled, and then reboot or wait for the next reboot.

Second, AppArmor, this pit dad and selinux the same pit dad, it also to the MySQL can use the directory permissions made restrictions
In/etc/apparmor.d/usr.sbin.mysqld This file, there are two lines that specify the data file path permissions that MySQL uses

/VAR/LIB/MYSQL/R,
/var/lib/mysql/** Rwk,

You must have seen it,/var/lib/mysql/. mysql installed the data file default path, AppArmor control here mysqld can use the directory permissions
I want to move the data file to/data/mysql, so in order to make mysqld can use/data/mysql this directory, according to the above two, add the following two can be

/DATA/MYSQL/R,
/data/mysql/** Rwk,

Restart Apparmor,/etc/inid.d/apparmor restart

After that, you will be able to do what you want to do!

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.