Moving MySQL datadir on development machine - mysql

Operating System: Ubuntu 18.04
MySQL version: Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)
My system is set-up so that Ubuntu is running on a 128gb SSD, with a separate 1TB SSD for storage. This system is dual-boot with Windows 10 Pro and Ubuntu 18.04. The storage drive is NTFS formatted.
I would like to move the MySQL datadir over to the storage drive, because my OS drive isn't big enough.
I've been following the tutorial on this URL: https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04
I've gotten to "Step 4 — Restarting MySQL" in the tutorial. Up to this point, I've followed everything to a T, no missed commas, forward slashes, etc. All done exactly as described (I've checked to make sure this is true numerous times)
When I enter the terminal command
sudo systemctl start mysql
I get the following output
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
Following this output, I enter the following command into the terminal
systemctl status mysql.service
and receive the following output
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-03-31 22:36:46 CDT; 38s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 7368 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 7316 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 7368 (code=exited, status=1/FAILURE)
Status: "Server startup in progress"
Error: 13 (Permission denied)
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.436713Z 0 [Warning] [MY-010091] [Server] Can't create test file /media/user/storage/mysql_datadir/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.436796Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 7368
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.439912Z 0 [Warning] [MY-010091] [Server] Can't create test file /media/user/storage/mysql_datadir/mysql/mysqld_tmp_file_case_insensitive_test.lower-test
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.439923Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /media/user/storage/mysql_datadir/mysql/ is case insensitive
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.439961Z 0 [ERROR] [MY-013276] [Server] Failed to set datadir to '/media/user/storage/mysql_datadir/mysql/' (OS errno: 13 - Permission denied)
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.440049Z 0 [ERROR] [MY-010119] [Server] Aborting
Mar 31 22:36:46 user-desktop mysqld[7368]: 2020-04-01T03:36:46.440146Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.19) MySQL Community Server - GPL.
Mar 31 22:36:46 user-desktop systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Mar 31 22:36:46 user-desktop systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 31 22:36:46 user-desktop systemd[1]: Failed to start MySQL Community Server.
Seeing that this was a permissions error (which should have been avoided using the -av tags when copying the original directory to the new drive) I entered in the following command to give open permissions to the entire drive.
sudo chmod a+rwx /media/user/storage/
to check the permissions I enter
ls -ls /media/user/storage/mysql_datadir
with output
total 12
12 drwxrwxrwx 1 root root 12288 Mar 31 02:45 mysql
I've also made sure the full file path to the new datadir is lowercase to avoid conflict between the two file systems.
I still cannot get MySQL to start.
I'd appreciate any help. Thank you in advance.
Edit:
namei -mo /media/user/storage/mysql_datadir
f: /media/user/storage/mysql_datadir
drwxr-xr-x root root /
drwxr-xr-x root root media
drwxr-x--- root root user
drwxrwxrwx root root storage
drwxrwxrwx root root mysql_datadir

Based on your post seems that you are having permission issue along with owner of the "data directory" must always be mysql.
STOP your mysql service if it's running.
Consider below example:
my.cnf looks:
#
# Original path change to avoid space issue on server
#
datadir=/var/lib/mysql
Now you change this datadir in your my.cnf file like:
#
# Original path change to avoid space issue on server
#
#datadir=/var/lib/mysql
datadir=/media/user/storage/mysql_datadir
After this check the permission:
cd /media/user/storage/mysql_datadir
ls -al
output:
drwxr-x--x 40 mysql mysql 4096 Mar 27 00:01 mysql
If this is not output then execute below command:
chmod -Rf 0751 /media/user/storage/mysql_datadir
chown -Rf mysql:mysql /media/user/storage/mysql_datadir
Finally
START your mysql service now.

I had the same problem/solution as Pratik, after following the instructions to define a new datadir in
/etc/mysql/mysql.conf.d/mysqld.conf
and
/etc/apparmor.d/usr.sbin.mysqld
I modified my fstab to mount to
/mnt
instead of
/media/[username]
and mysql start up without any errors. no additional permissions to set other than the mysql directory. My issue was on Ubuntu 18.04 must be something special about the /media mount point

Related

MariaDB server is down but I can still login with mysql client (?)

MariaDB 10.3.8, Ubuntu 18 LTS.
When I check for the database status, I see that MariaDB is down. But I can login using the mysql client command. Is something wrong? How could I debug this?
sudo service mariadb status
mariadb.service - MariaDB 10.3.8 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: failed (Result: timeout) since Wed 2019-02-13 08:43:11 IST; 1min 0s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Process: 3293 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Process: 3712 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 3706 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Process: 3693 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
Main PID: 3878 (mysqld)
Tasks: 13 (limit: 4915)
CGroup: /system.slice/mariadb.service
└─3878 /usr/sbin/mysqld
# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 2346 user_running_mariadb 31u IPv6 28910 0t0 TCP *:mysql (LISTEN)
ps uax | grep mysql
root 2049 0.0 0.0 4628 1812 ? S 08:40 0:00 /bin/sh /usr/bin/mysqld_safe
user_running_mariadb 2346 0.1 0.4 3005364 114444 ? Sl 08:40 0:02 /usr/sbin/mysqld --basedir=/usr --datadir=/my_db_files_dir --plugin-dir=/usr/lib/mysql/plugin --user=user_running_mariadb --skip-log-error --pid-file=/my_db_rundir/run/mysqld.pid --socket=/my_db_rundir/run/mysqld.sock --port=3306
#/my_db_rundir/run# ls -l
-rw-rw---- 1 user_running_mariadb group_running_mariadb 5 Feb 13 08:40 mysqld.pid
srwxrwxrwx 1 user_running_mariadb group_running_mariadb 0 Feb 13 08:40 mysqld.sock
#/my_db_rundir/run# cat mysqld.pid
2346
I can login:
mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 145
Server version: 10.3.8-MariaDB-1:10.3.8+maria~bionic-log mariadb.org
inary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input
tatement.
MariaDB [(none)]>
Additional outputs:
Error log:
2019-02-13 8:52:13 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2019-02-13 8:52:13 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2019-02-13 8:52:13 0 [Note] InnoDB: Unable to open the first data file
2019-02-13 8:52:13 0 [ERROR] InnoDB: Operating system error number 11 in a file operation.
2019-02-13 8:52:13 0 [ERROR] InnoDB: Error number 11 means 'Resource temporarily unavailable'
journalctl -u mariadb.service
Feb 13 08:51:31 my_host systemd[1]: mariadb.service: Start operation timed out. Terminating.
Feb 13 08:52:13 my_host systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Feb 13 08:52:13 my_host systemd[1]: mariadb.service: Failed with result 'timeout'.
Feb 13 08:52:13 my_host systemd[1]: Failed to start MariaDB 10.3.8 database server.
The service is timed out ('Result: timeout'), and the service has the systemd configuration SendSIGKILL=no, which means systemd has just let mysqld continue running.
Why it time out? take a look at journalctl -u mariadb.service.
I could fix the issue, however I'm not completely sure about the root cause and what really fixed the issue. Still, perhaps this information helps others facing the same issue.
Reinstalled MariaDB and upgraded to 10.3.12. This wasn't probably needed because I kept hitting the same issue after the upgrade.
After reboot, noticed that msyqld status showed as active while mariadb as inactive:
/ati/mariadb/logs# sudo service mysql status
Loaded: loaded (/etc/init.d/mysql; generated)
Active: active (running)
Docs: man:systemd-sysv-generator(8)
Process: 1650 ExecStart=/etc/init.d/mysql start (code=exited, status=0/SUCCESS)
Tasks: 39 (limit: 4915)
CGroup: /system.slice/mysql.service
─2003 /bin/sh /usr/bin/mysqld_safe
─2301 /usr/sbin/mysqld --basedir=/usr...
└─2302 logger -t mysqld -p daemon error
sudo service mariadb status
mariadb.service - MariaDB 10.3.12 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; disabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: inactive (dead)
In MariaDB web site, found the way of enabling mariadb service, with
systemctl enable mariadb
Now, it works again.

Moving Mysql data directory

I am having trouble moving my mysql data directory to a new location. I am running Linux Mint 17, MySQL 5.7.19. I have tried the instructions in these two locations:
How to change MySQL data directory?
This answer:
https://stackoverflow.com/a/10209282/7850358
and this guide:
https://www.digitalocean.com/community/tutorials/how-to-move-a-mysql-data-directory-to-a-new-location-on-ubuntu-16-04
I believe I am having a similar problem as this question: https://dba.stackexchange.com/questions/101732/how-do-i-move-a-mysql-data-directory-to-an-external-hard-drive
I rsync'ed the data from /var/lib/mysql to /media/mike/DataBase. The directory exists, and is properly specified in the /etc/mysql/mysql.conf.d/mysqld.cnf, and I created an alias in /etc/apparmor.d/tunables/alias. I made sure the permissions on the folder were correct: drwx------ 11 mysql mysql 4096 Jan 21 16:52 mysql.
I restart apparmor, no problems.
I restart the mysql server - I get this:
Thudbucket mike # sudo systemctl start mysql
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
Thudbucket mike # systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Sun 2018-01-21 17:10:34 EST; 12s ago
Process: 22295 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 22288 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 22295 (code=exited, status=1/FAILURE); : 22296 (mysql-systemd-s)
CGroup: /system.slice/mysql.service
└─control
├─22296 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─22332 sleep 1
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.308875Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.308930Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.453972Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server opti
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.454033Z 0 [Warning] Can't create test file /media/mike/DataBase/mysql/Thudbucket.lower-test
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.454054Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.19-0ubuntu0.16.04.1) starting as process 22295 ...
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.455725Z 0 [Warning] Can't create test file /media/mike/DataBase/mysql/Thudbucket.lower-test
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.455735Z 0 [Warning] Can't create test file /media/mike/DataBase/mysql/Thudbucket.lower-test
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.455760Z 0 [ERROR] failed to set datadir to /media/mike/DataBase/mysql/
Jan 21 17:10:34 Thudbucket mysqld[22295]: 2018-01-21T22:10:34.455774Z 0 [ERROR] Aborting
Jan 21 17:10:34 Thudbucket systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
I've tried just about everything I could find online. I even read the manual, for a change. For some reason, moving the data directory to any location but /var/lib/mysql results in errors for me.
I ultimately had better luck with this hack:
https://askubuntu.com/a/663945/785778
## copy with permissions intact:
rsync -avzh /var/lib/mysql /path/to/new/place
## back up original
mv /var/lib/mysql /var/lib/_mysql
## create a new empty directory in place of old:
mkdir /var/lib/mysql
## bind mount the new location to the old:
mount -B /path/to/new/place /var/lib/mysql
After restarting the mysql, everything worked fine.
Ironically - symbolic linking did not work
EDIT
This appears to be a bug, but the provided solution doesn't resolve the issue for me:
https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1574782
https://forums.mysql.com/read.php?11,653198,653198#msg-653198
The bug works like this: MySQL at startup looks for the presence of the /var/lib/mysql/ and /var/lib/mysql/mysql directories. The solution provided to leave the /var/lib/mysql and /var/lib/mysql/mysql directories but remove the contents and add the new datadir path to the apparmor configuration file (/etc/apparmor.d/usr.sbin.mysqld) and reload it (/etc/init.d/apparmor reload).
But to repeat, while it appears I have the same issue (MySQL keeps looking for the datadir at /var/lib/mysql), the only solution that worked for me was to mount the data directory at /var/lib/mysql/.
Return this error
2021-02-12T19:02:55.910704Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2021-02-12T19:02:55.910710Z 0 [ERROR] Fatal error: Failed to initialize ACL/grant/time zones structures or failed to remove temporary table files.
2021-02-12T19:02:55.910731Z 0 [ERROR] Aborting

Can not run "Percona XtraDB Cluster 5.7" on Centos 7

I want used "Percona XtraDB Cluster 5.7".
So I installed "Percona XtraDB Cluster" by official guide.
https://www.percona.com/doc/percona-xtradb-cluster/5.7/install/yum.html#yum
But when I add nodes to cluster, my mysql coudn't run.
$ sudo service mysql start
Job for mysql.service failed. See 'systemctl status mysql.service' and 'journalctl -xn' for details.
$ sudo cat /var/log/messages
...
Jan 13 04:19:25 localhost mysqld_safe: 2017-01-12T19:19:25.588436Z mysqld_safe Skipping wsrep-recover for empty datadir: /var/lib/mysql
Jan 13 04:19:25 localhost mysqld_safe: 2017-01-12T19:19:25.590385Z mysqld_safe Assigning 00000000-0000-0000-0000-000000000000:-1 to wsrep_start_position
Jan 13 04:19:27 localhost mysql-systemd: State transfer in progress, setting sleep higher
Jan 13 04:19:40 localhost mysqld_safe: 2017-01-12T19:19:40.723030Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
Jan 13 04:19:47 localhost mysql-systemd: /usr/bin/mysql-systemd: 137 行: kill: (19791) - そのようなプロセスはありません
Jan 13 04:19:47 localhost mysql-systemd: ERROR! mysqld_safe with PID 19791 has already exited: FAILURE
Jan 13 04:19:47 localhost systemd: mysql.service: control process exited, code=exited status=1
Jan 13 04:19:47 localhost mysql-systemd: WARNING: mysql pid file /var/run/mysqld/mysqld.pid empty or not readable
Jan 13 04:19:47 localhost mysql-systemd: ERROR! mysql already dead
Jan 13 04:19:47 localhost systemd: mysql.service: control process exited, code=exited status=2
...
I used centos7 on 3 virtual machine.
And my /etc/my.cnf is default except following code.
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
wsrep_cluster_name=pxc-cluster
wsrep_cluster_address=gcomm://192.168.70.61,192.168.70.62,192.168.70.63
wsrep_node_name=pxc1
wsrep_node_address=192.168.70.61
wsrep_sst_method=xtrabackup-v2
wsrep_sst_auth=sstuser:passw0rd
pxc_strict_mode=ENFORCING
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
What should I check?
For the first node, you should bootstrap it, instead of just starting it. On CentOS7 you can do so with:
systemctl start mysql#bootstrap.service
Then, you can go ahead and start nodes 02 and 03 normally:
systemctl start mysql

Mariadb doesn't starts. Control process Exited

I am trying to start mariadb with systemctl start mariadb also tried using sudo along.
This is what it says
Job for mariadb.service failed because the control process exited with
error code. See "systemctl status mariadb.service" and "journalctl
-xe" for details.
I saw this at many places but nothing helped.
It fails, I removed, installed again, nothing happened.
This is a part of /var/log/messages
Jun 17 18:03:09 controller systemd: Starting MariaDB 10.1 database
server...
Jun 17 18:03:09 controller mysqld: 2016-06-17 18:03:09 140477178509440
[Note] /usr/libexec/mysqld (mysqld 10.1.12-MariaDB) starting as process 120408 ...
Jun 17 18:03:12 controller systemd: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jun 17 18:04:13 controller systemd: mariadb.service: control process exited, code=exited status=3
Jun 17 18:04:13 controller systemd: Failed to start MariaDB 10.1 database server.
Jun 17 18:04:13 controller systemd: Unit mariadb.service entered failed state.
Jun 17 18:04:13 controller systemd: mariadb.service failed.
I am really new to CentOS and mariadb, so I don't know how to proceed.
EDIT
The mariadb.log says
2016-06-17 19:24:39 140652810123392 [Note] Server socket created on IP: '::'.
2016-06-17 19:24:39 140652810123392 [ERROR] Can't start server: Bind on TCP/IP port. Got error: 98: Address already in use
2016-06-17 19:24:39 140652810123392 [ERROR] Do you already have another mysqld server running on port: 3306 ? 2016-06-17 19:24:39 140652810123392 [ERROR] Aborting
This is my my.cnf
#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# This group is read by the server
#
[mysqld]
port=5555
bind-address = 10.23.77.68
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d
I tried adding a line in my.cnf
port=5555
Didn't help, mariadb.log says the same thing as I have mentioned earlier.
I solved as follows:
After installing
Run: > mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/
Then: >mysql_secure_installation
And then: systemctl start mariadb
With this this, I can resolved.
Just remove following files at location
/var/lib/mysql
ib_logfile0
ib_logfile1
fuser -k 3306/tcp will solve the probem.
-k is to Kill processes accessing the file.

Fail to move mysql's data directory

I'm trying to move the data directory of mysql, here are my steps:
use show variables like 'datadir' to know my datadir is /var/lib/mysql/
cd /var/lib/mysql/
# mv * /home/elderry/db/
gvim /etc/mysql/my.cnf
Add this line in [mysqld] section:
datadir = /home/elderry/db/
# systemctl start mysqld
Job for mysqld.service failed. See 'systemctl status mysqld.service' and 'journalctl -xn' for details.
Then I tried: systemctl status mysqld.service
Result:
mysqld.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled)
Active: activating (start-post) (Result: exit-code) since Tue 2013-07-30 14:31:53 CST; 13s ago
Process: 14174 ExecStart=/usr/bin/mysqld --pid-file=/run/mysqld/mysqld.pid (code=exited, status=1/FAILURE)
Control: 14175 (mysqld-post)
CGroup: name=systemd:/system/mysqld.service
└─control
├─14175 /bin/sh /usr/bin/mysqld-post
└─14293 sleep 1
Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [Warning] Can't create test file /home/elderry/db/Kanone.lower-test
Jul 30 14:31:53 Kanone mysqld[14174]: [71B blob data]
Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [ERROR] Aborting
Jul 30 14:31:53 Kanone mysqld[14174]: 130730 14:31:53 [Note] /usr/bin/mysqld: Shutdown complete
Jul 30 14:31:53 Kanone systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
If I want to start mysql manually: mysql -u root -p
output:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/run/mysqld/mysqld.sock' (2)
What shoud I do for now?
It seems you moved the datadir to your home directory. I think that when you start mysqld via your service manager (in your case systemd) it will be started as an unprivileged user (most likely mysql). I strongly doubt that this user has privileges to access the homedir of the user elderry.
So the solution would either be moving your datadir to a more suitable location like /var/lib/mysql and chown this directory to the user under which mysql runs. Or that you give the mysql user privileges that he can acces the homedir of elderry.
When installing MariaDB, it creates user and group mysql automatically that own all data files, so if you move data dir, make sure that all folder, subfoler, files in new data directory are owned by user mysql and group mysql.
Also check if your partition is not full, which was my case.
For an unknown reason, moving the data to another partition did not work either.
So for a quick fix, instead of messing with llvm or gparted, I reduced my /swapfile size.