If you need to reinstall MariaDB on DirectAdmin server. Here is how you can do it.
First, make sure to dump all existing databases
cd /usr/local/directadmin/custombuild/
./build update
./build mysql_backup
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
./build mysql
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:
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:
cd /usr/local/directadmin/custombuild/mysql_backups
mysql mysql -p < mysql.sql
Enter the root's password when asked.
Restart SQL-server:
systemctl restart mysqld
And now we can restore all databases:
cd /usr/local/directadmin/custombuild/mysql_backups
wget http://files1.directadmin.com/services/all/mysql/restore_sql_files.sh
chmod 755 restore_sql_files.sh
./restore_sql_files.sh
That's it.