If you need to reinstall MariaDB on DirectAdmin server. Here is how you can do it.
Dump MySQL tables
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.
Copy MySQL config file
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
Remove existing MariaDB
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:
As soon as the installation complete we need to set a password.
Set root's 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.
Recover mysql database
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
Restore other databases
And now we can restore all databases:
chmod 755 restore_sql_files.sh