after install I'm trying to move the database location
On fedora:
# su
# systemtcl stop mariadb
# cp -rp /var/lib/mysql /home
# chown mysql.mysql /home/mysql
Next i'm editing the file /etc/my.cnf.d/mariadb-server.cnf
from
[mysqld]
datadir=/var/lib/mysql/
socket=/var/lib/mysql.sock
to
[mysqld]
datadir=/home/mysql/
socket=/home/mysql.sock
then
# systemctl start mariadb
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
So
systemctl status mariadb
● mariadb.service - MariaDB 10.0 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2016-06-29 17:51:18 CEST; 29s ago
Process: 6488 ExecStopPost=/usr/libexec/mysql-wait-stop (code=exited, status=0/SUCCESS)
Process: 3103 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
Process: 6304 ExecStartPost=/usr/libexec/mysql-wait-ready $MAINPID (code=exited, status=1/FAILURE)
Process: 6303 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=1/FAILURE)
Process: 6259 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Process: 6231 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
Main PID: 6303 (code=exited, status=1/FAILURE)
Jun 29 17:51:17 123PUB-PC systemd[1]: Starting MariaDB 10.0 database server...
Jun 29 17:51:17 123PUB-PC mysqld_safe[6303]: 160629 17:51:17 mysqld_safe Logging to '/var/log/maria...g'.
Jun 29 17:51:17 123PUB-PC mysqld_safe[6303]: mkdir: impossible de créer le répertoire « /home/mysql…xiste
Jun 29 17:51:17 123PUB-PC mysqld_safe[6303]: Fatal error Can't create database directory '/home/mys...ck'
Jun 29 17:51:17 123PUB-PC systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
Jun 29 17:51:18 123PUB-PC systemd[1]: mariadb.service: Control process exited, code=exited status=1
Jun 29 17:51:18 123PUB-PC systemd[1]: Failed to start MariaDB 10.0 database server.
Jun 29 17:51:18 123PUB-PC systemd[1]: mariadb.service: Unit entered failed state.
Jun 29 17:51:18 123PUB-PC systemd[1]: mariadb.service: Failed with result 'exit-code'.
Hint: Some lines were ellipsized, use -l to show in full.
So it seem that mysql don't have write permission on home/mysql, but :
# ls -la /home/mysql
drwxr-xr-x. 4 mysql mysql 4096 Jun 29 17:38 .
drwxr-xr-x. 5 root root 4096 Jun 29 17:54 ..
-rw-rw----. 1 mysql mysql 16384 Jun 29 17:38 aria_log.00000001
-rw-rw----. 1 mysql mysql 52 Jun 29 17:38 aria_log_control
-rw-rw----. 1 mysql mysql 12582912 Jun 29 17:38 ibdata1
-rw-rw----. 1 mysql mysql 50331648 Jun 29 17:38 ib_logfile0
-rw-rw----. 1 mysql mysql 50331648 Jun 29 17:05 ib_logfile1
-rw-rw----. 1 mysql mysql 0 Jun 29 17:05 multi-master.info
drwx------. 2 mysql mysql 4096 Jun 29 17:05 mysql
-rw-r--r--. 1 mysql mysql 16 Jun 29 17:05 mysql_upgrade_info
drwx------. 2 mysql mysql 4096 Jun 29 17:05 performance_schema
I don't see any difference with the main directory.
So what next?
Best Answer
It's an SELinux issue. But to make sure of that disable enforcing just for testing.
Testing
Execute this in your server (root only) to temporarily disable SELinux
Now you can start the server
Connect using mysql client but first modify the configuration on file
/etc/my.cnf.d/client.cnf
to use the new socket file.If everything was OK then you'll be able to connect to your newly located database.
Stop the server
Permanent solution with SELinux configuration
SELinux prevents mysqld to work (read, write, access) in any directory other than the default.
To overcome this you need to modify this behavior so SELinux grants permissions to your new location.
Get the context. Listing may differ but should show mysqld_db_t context.
Add the context obtained (mysqld_db_t) to the mapping for
/home/mysql
.Apply the context
Check that the context is applied
Everything is now in place. You should have no problem in re enforcing SELinux and get your server UP.