MYSQL datadir default -> /home/mysql

Hello!

sudo systemctl stop mysql
sudo rsync -av /var/lib/mysql /home/mysql

nano /etc/mysql/my.cnf 

#datadir=/var/lib/mysql
datadir=/home/mysql

save

and

2020-08-08 22:36:41 0 [Note] /usr/sbin/mysqld (mysqld 10.4.13-MariaDB-1:10.4.13+maria~buster) starting as process 2496 ...
 mysqld[2496]: 2020-08-08 22:36:42 0 [Warning] Can't create test file /home/mysql/teszt.lower-test


Why?

permissions, apparmor?

Premissions: The rights are fine.
Apparmor: none.

[email protected]:~# ls -l /home
összesen 32
drwxr-xr-x+ 11 root root 4096 júl 4 19:37 admin
drwxr-xr-x 2 hoho hoho 4096 júl 4 18:13 hoho
drwxrwxrwx 8 mysql mysql 4096 aug 8 22:31 mysql
drwxr-xr-x+ 12 root root 4096 júl 5 00:17 pronaikalman-1
drwxr-xr-x+ 11 root root 4096 júl 4 21:28 teszt1
drwxrwxrwx 2 root root 4096 aug 8 22:49 tmp
drwxr-xr-x+ 11 root root 4096 júl 4 21:52 vbalazs-1
drwxrwxrwx 4 root root 4096 júl 12 13:46 webtarhely
[email protected]:~# ls -l /home/mysql
összesen 188568
-rw-rw---- 1 mysql mysql 114688 júl 9 15:17 aria_log.00000001
-rw-rw---- 1 mysql mysql 52 júl 9 15:17 aria_log_control
-rw-r–r-- 1 root root 0 júl 4 19:25 debian-10.4.flag
-rw-rw---- 1 mysql mysql 4668 júl 9 15:17 ib_buffer_pool
-rw-rw---- 1 mysql mysql 79691776 júl 9 15:17 ibdata1
-rw-rw---- 1 mysql mysql 50331648 aug 8 22:31 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 júl 4 19:25 ib_logfile1
-rw-rw---- 1 mysql mysql 12582912 aug 8 22:31 ibtmp1
-rw-rw---- 1 mysql mysql 0 júl 4 19:34 multi-master.info
drwx------ 2 mysql mysql 4096 júl 4 20:36 mysql
-rw-rw---- 1 root root 16 júl 4 20:36 mysql_upgrade_info
drwx------ 2 mysql mysql 4096 júl 4 20:36 performance_schema
drwx------ 2 mysql mysql 4096 júl 4 19:37 phpmyadmin
drwx------ 2 mysql mysql 4096 júl 5 00:17 [email protected]_r
drwx------ 2 mysql mysql 4096 júl 4 19:36 roundcube
drwx------ 2 mysql mysql 4096 júl 4 21:52 [email protected]_mad

I think that you may have missed a few steps:
Relocate mySQL data directory

Alternatively:
Tecmint version

Solved:

nano /etc/systemd/system/mysqld.service
ProtectHome=false

SAVE. and service mysql start and work! :slight_smile:

1 Like