If you need to reinstall MariaDB on DirectAdmin server. Here is how you can do it.
First, make sure to dump all existing databases
You should have sufficient free disk space for it and it might take a while to dump big databases. You should never skip this step.
If you have customized the file /etc/my.cnf you will need to copy it to a safe place:
\cp -p /etc/my.cnf /etc/my.cnf~poralix
On CentOS and CloudLinux servers run the following command:
rpm -qa | grep mariadb -i | xargs rpm -e --noscripts
Here you might need to kill a running copy of a SQL-server.
Later after you re-install the SQL-server you can remove the old data directory, but now it would be better to rename folder.
\mv /var/lib/mysql /var/lib/mysql.moved
It you have a customized version of settings for SQL-server it is the right time to install it.
\cp -p /etc/my.cnf~poralix /etc/my.cnf
Now we do a fresh installation of a SQL-server:
cd /usr/local/directadmin/custombuild/ ./build update
As soon as the installation complete we need to set a password.
By default when installing MariaDB, there might be empty root's password, so we need to set it. It can be done with a help of mysql_secure_installation:
Follow the steps, and answer Yes, when asked whether or not you want to set a password.
First we recover mysql database to restore all users accounts:
mysql mysql -p < mysql.sql
Enter the root's password when asked.
systemctl restart mysqld
And now we can restore all databases:
chmod 755 restore_sql_files.sh