Mysql prompts [Warning] Cant create test file xxx lower-test

Source: Internet
Author: User

In linux, I encountered the prompt mysql prompts [Warning] Cant create test file xxx lower-test. If you encounter such problems, let's take a look at the solution.


I think you must search for this title from seo/seo.html "target =" _ blank ">! You must change the default data directory installed in mysql!
You have modified the value of datadir in my. cnf.

First, view database logs.

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 have already chown and chmod the owner and permissions of the new data directory or its parent path several times.

You have tried service mysql start countless times, or/etc/init. d/mysql start, and mysql_install_db!

Congratulations! You saw this article. I found a solution after being stuck in the system for a few hours.

There are two reasons for this. Either of these causes will cause you to be notified of this warning by the system. If you are not a professional linux system security engineer or you are just a PHP programmer and have not studied system security in depth, you will not find the answer easily.

First, selinux, remember to install redhat on the Character interface when I was studying (a very old operating system ...) When there is such an option, we usually listen to the advice of the predecessors, change the default value to do not install it. However, if selinux is enabled on the machine that you want to operate on, it does not allow your mysql to operate on mysql_install_db at the new target location, and a warning is displayed in the title. A simple solution is to temporarily disable selinux using commands so that your operations can continue.
Setenforce 0

However, it is best to use a permanent method so that this product can be retained after restart.

Modify selinux = disabled in the/etc/SELINUX/config file, and restart or wait for the next restart.

Second, apparmor is the same as selinux. It also limits the directory permissions that mysql can use.
These two lines are available in the/etc/apparmor. d/usr. sbin. mysqld file, which specifies the data file path permission used by mysql.

/Var/lib/mysql/r,
/Var/lib/mysql/** rwk,

You must have seen that/var/lib/mysql/is the default path of the data file installed in mysql. apparmor controls the directory permissions that mysqld can use.
I want to move the data file to/data/mysql. In order to enable mysqld TO USE THE/data/mysql directory, add the following two files as shown above.

/Data/mysql/r,
/Data/mysql/** rwk,

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

Then you can do what you want!

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.