Hi Nik,
The above steps are not enough for latest Plesk Obsidian Version 18.0.62 which is running on AlmaLinux 8.10. With a normal server which is not having plesk panel, above steps are enough. But with latest panel, the above steps are not enough. With the above steps, mysql service will come up, but plesk panel will start throwing database errors. The database connections via websites will also wont work. Plesk panel still looks for /var/lib/mysql/mysql.sock. file hence the issues. I have followed the below steps and was able to make this working.
In my case i was trying to move data directory from "/var/lib/mysql" to "/home/MYSQL_DATA/" as root partion was not having enough space and databases in the server was fast growing. I had 8TB partition for /home/.
1. Take necessary backups of mysql databases so that if some thing goes wrong, we can restore data using the same. You can refer below link
Stop Mysql / Mariadb service. In mycase it was mariadb.
2. Copy mysql data directory to new location
cp -pr /var/lib/mysql /home/MYSQL_DATA/
chown -R mysql.mysql /home/MYSQL_DATA/
4. Move existing /var/lib/mysql
mv /var/lib/mysql /var/lib/mysql _bak
5. Edit my.cnf loaded, update the below parameter,
Important note:- socket=/var/lib/mysql/mysql.sock this should remain unchanged. In normal procedure
socket paramer can also be changed.
datadir=/home/MYSQL_DATA/
6. Recrate /var/lib/mysql as plesk looks for the same and changing the path to the socket can cause the Plesk to crash. Just folder is enough, we just it for creation of socket file during start process of service.
7. Update the system demon configuration file for mysql / mariadb service. We have to update ExecStart parameter with new data directory path.
edit file /usr/lib/systemd/system/mariadb.service
ExecStart=/usr/libexec/mysqld --basedir=/usr $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
To
ExecStart=/usr/libexec/mysqld --datadir=/home/MYSQL_DATA/mysql --basedir=/usr $MYSQLD_OPTS $_WSREP_NEW_CLUSTER
systemctl daemon-reload
8. Create a backup of /etc/passwd and change mysql users home directory.
mysql:x:27:27:MariaDB Server:/home/MYSQL_DATA:/sbin/nologin
9. Update /etc/psa/psa.conf with a path to the new mysql directory, so that plesk understands the new path. Change MYSQL_VAR_D from /var/lib/mysql to below.
Important note:- socket MYSQL_SOCKET should remain unchanged.
MYSQL_VAR_D /home/MYSQL_DATA/mysql
10. For Almal linux, SeLinux should be disabled.
11. Start the Mysql / Mariadb service.
I was able to make the mysql data directory move with the above step of steps. All worked perfect.