DirectAdmin Knowledge Base and Support

DirectAdmin is a web panel for a simple administration of both virtual and dedicated servers. DirectAdmin is faster, safe and more powerful than any other CP. And we know how to customize and support it.

How to reinstall MariaDB on DirectAdmin server

| 15:23:07 09.08.2019

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

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.

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.

Rename /var/lib/mysql/

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

Re-install /etc/my.cnf

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

Re-install MariaDB:

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.

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:

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

Restore other databases

And now we can restore all databases:

cd /usr/local/directadmin/custombuild/mysql_backups
chmod 755

That's it.

About Us
We are a team of professionals, and specialize in installation, configuring and managing of remote virtual and dedicated servers powered by Linux/Unix-like OS with DirectAdmin. We support various sets of software, including web-servers Apache, Nginx; internet domain name servers Bind, PowerDNS; mail-servers with POP3, IMAP and SMTP, FTP-servers, etc. After years of working through the most complex server challenges our team has gathered valuable experience and universal solutions suitable for everyday tasks. We are here to lend you a helping hand and take care of your servers in order to let you have enough time to do more of what you love.

All of the information and data on this site is for informational purposes only and is provided for the convenience of the user.
Powered by: Amiro.CMS - Free edition