Tag Archives: ArchLinux starts error

ArchLinux starts error after modifying MariaDB database path Can’t create test file /xxxxx/xxxxx-test

Install MariaDB first, there is nothing special about this step.

>$ sudo pacman- Sy
 >$ sudo pacman -S extra/mariadb

After the installation is complete, pay attention to the prompts, which will ask us to initialize MariaDB.

sudo mariadb- install -db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Among them –datadir is the path where the database is located, I modified it to the path /home/mariadb.

 

Next, modify the configuration file and add the new database path.

>$ sudo vim /etc/my.cnf.d/ server.cnf
[mysqld]
datadir =/home/mariadb

 

Edit the /usr/share/mysql/policy/apparmor/usr.sbin.mysqld file and add the new path, otherwise the database service cannot be started.

Search for the default path of the database /var/lib/mysql in this file, and configure our new path in the same way.

 

The last step is to modify the service startup script, otherwise the service still cannot be started.

>$ sudo vim /lib/systemd/system/ mariadb.service
ProtectHome = false

Change ProtectHome=true to ProtectHome=false.

 

Now you can start the database.

>$ sudo systemctl daemon- reload
 >$ sudo systemctl start mariadb
# If you need to boot automatically, execute the following command
>$ sudo systemctl enable mariadb