Reputation: 6102
I installed MariaDB server 13.0 on Centos 7.0, disabled SELinux. I started the MariaDB server successfully. After that, I want to custom my database data directory. So here are my steps:
/var/lib/mysql
directorycp -Rp /var/lib/mysql /disk1/mysql
datadir
from my.cfg.d/server.cfg
: datadir=/disk1/mysql
Then I stop and start again the MariaDB server using the following command:
sudo systemctl start mariadb
Everything runs successfully. I can create a new database, a new table and I see it changes the data in the new path. However, if I remove all directory /var/lib/MySQL
. I cannot start my server anymore.
Here is the log when running command systemctl status mariadb.service
- mariadb.service - MariaDB 10.3.16 database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/mariadb.service.d
-custom.conf, migrated-from-my.cnf-settings.conf Active: failed (Result: exit-code) since Fri 2019-06-28 11:55:59 +07; 4s ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Process: 23296 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE) Process: 23281 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: 23277 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) Main PID: 23296 (code=exited, status=1/FAILURE)
Status: "MariaDB server is down"
My old database server, I can delete /var/lib/mysql
. Please explain to me the reason why.
Upvotes: 0
Views: 1827
Reputation: 6102
I have checked MySQL log and it has a line with content:
"cannot read file /var/lib/mysql/mysql.sock"
That is my old directory so I think I need to custom mysql.sock
.
In /etc/my.cnf.d/server.cnf
:
[mysqld]
datadir=/disk1/mysql/
socket=/disk1/mysql/mysql.sock
In /etc/my.cnf.d/client.cfg
:
[client]
# we need to configure this. so when we type mysql -u user. mysql can look up socket's location.
socket=/disk1/mysql/mysql.sock
After that, I can run and connect successfully to my MySQL instance. I don't know why there is no tutorial point out this point. But this is a way I used to fix my problem.
Upvotes: 1