systemctl start mariadb error but mysql running

codepoet

Member
Jun 28, 2017
16
2
3
Canada
cPanel Access Level
Root Administrator
Hello, so I needed to move my datadir of MariaDB on my cPanel server because as many it happens, I kept the default config of partitions, and didn't think about it, so I had 20GB and it was getting full, and obviously the main folder taking space was /var/lib/mysql

Long story short, I moved the mysql folder to the /home/mysql (/home partition has plenty of space free and is on the same SSD that /var). Simple rsync the files, changing the config and reboot the database server, created a symlink from the old to the new folder.

Now I noticed something, and maybe this is normal and has always been like this.

When I use /scripts/restartsrv_mysql it restarts the database server, it always says mysql but its MariaDB.

Why when I manually restart the mariadb server using systemctl it doesnt work but using the word mysql instead it restarts mariadb, I am just confused, it it all just the same thing ? does both need to run ?

Just to be sure, I added protecthome=false to the mariadb.service config just in case

Thank you for any explanations/guidance/help !
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463

codepoet

Member
Jun 28, 2017
16
2
3
Canada
cPanel Access Level
Root Administrator
Hello @cPanelMichael

Thank you. Actually I didn't even use the symlink or ebev a mount. By changing the datadir in the my.cnf all is good and running well.

Actually I'm just trying to understand the other part about why on a cpanel server I have mariadb and when checking the status of the mariadb service it says inactive (dead) and if I run service mysql status I get mariadb running as a status
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
Hello @codepoet,

Here's an example of output I see on a test system running MariaDB:

Code:
 systemctl status mariadb
● mariadb.service - MariaDB 10.2.19 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Wed 2018-11-21 12:01:32 CST; 20s ago
If you're seeing "Inactive", then it's very likely related to the issued noted in my last response. If you're defining a location in /home as the data directory for MariaDB in the /etc/my.cnf file, then you must perform one of the following steps (from most-to-lease desirable):

1. Move the data directory back to the default location after increasing the size of the root filesystem or mounting a large enough filesystem under /var, /var/lib, or /var/lib/mysql, if necessary.

2. Remove any custom datadir option from /etc/my.cnf, remove any /var/lib/mysql symlink, and use a bind-mount from the non-default datadir location to /var/lib/mysql.

3. Use a drop-in configuration file to disable the systemd ProtectHome and ProtectSystem options for the MariaDB service (this is highly discouraged and should only be used as a last resort). EX

Code:
# cat /etc/systemd/system/mariadb.service.d/disable-protect.conf
[Service]
ProtectHome=false
ProtectSystem=false
# systemctl daemon-reload
# /scripts/restartsrv_mysql
Thank you.
 

codepoet

Member
Jun 28, 2017
16
2
3
Canada
cPanel Access Level
Root Administrator
Hello @cPanelMichael

I have already done those manipulations. Thank you for your guidance.

My only misunderstanding is how the database server is working if mariadb.service says inactive. I migrated from MySQL to mariadb when I installed whm/cpanel and I see mariadb when I login in ssh with the mysql command...

Have an idea ?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
My only misunderstanding is how the database server is working if mariadb.service says inactive. I migrated from MySQL to mariadb when I installed whm/cpanel and I see mariadb when I login in ssh with the mysql command...
Hello @codepoet,

It's normal for the mysql command to continue working after installing MariaDB. MariaDB is a drop-in replacement for MySQL, so commands such as "mysql" will continue to work. The system automatically detects and uses MariaDB in these situations.

mariadb.service says inactive.
You should not see an inactive status for MariaDB when running the systemctl status mariadb command. Could you open a support ticket so we can take a closer look at why that's happening? You can post the ticket number here and we'll link this thread to it.

Thank you.