How to Solve MYSQL Error: Can’t create test file xxx lower-test

In Linux, the prompt MySQL prompts [warning] cant create test file XXX lower test. Here are some friends who have encountered this kind of problem. Let’s have a look at the solution

I think you must have come in from the search engine! You must want to change the default installation of MySQL data directory
you have modified the value of dataDir in my.cnf

The first is to look at 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 about the owner and permission of the new data directory or its parent path

You’ve tried to service mysql start, or/etc/init.d/mysql start, or mysql start countless times_ install_ db!

Congratulations on reading this article. I found a solution after being trapped by the system for several hours

There are two reasons for this. Any one of them will cause you to be told the warning by the system. If you are not a professional Linux system security engineer, or if you are just a php programmer, and do not have in-depth research on system security, you will not be easy to find the answer

First, SELinux. I remember when I was a student, RedHat was installed on the character interface There is such an option, usually we listen to the advice of the predecessors, change the default value to not install it. But if the machine you are about to operate is running SELinux, it can really prevent your MySQL from running in the new target location_ install_ DB operation, and the title of the warning. A simple solution is to use the command to shut down SELinux temporarily so that your operation can continue
setenforce 0

But it’s best to use a permanent method so that you don’t want the goods after restart

Modify SELinux = disabled in/etc/SELinux/config file, and then restart or wait for the next restart

Second, AppArmor, which is the same as SELinux, also limits the directory permissions that MySQL can use
in the file/etc/apparmor.d/usr.sbin.mysqld, there are two lines that specify the data file path permissions that MySQL can use

/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

As you can see,/var/lib/MySQL/is the default path of the data files installed in MySQL before, and the permission of the directory where mysqld can be used is controlled by the app
I want to move the data files to/data/MySQL, so that mysqld can use the directory/data/MySQL, just follow the above two and add the following two

/data/mysql/ r,
/data/mysql/** rwk,

Restart the application,/etc/inid.d/application restart

 

Similar Posts: