How to Secure MySQL/MariaDB Database Server

Introduction

MySQL is a popular open source database server that provides data storage and retrieval services to businesses of all sizes. It is used in many applications and websites, including e-commerce stores, online forums, content management systems, and more. As such, it is essential to secure the MySQL database server in order to keep your data safe and prevent unauthorized access and protect against malicious attacks.

Secure a MySQL/MariaDB Database Server with Basic Security Measures

Databases are the backbone of many organizations and need to be kept secure from malicious threats. In order to ensure that your database system is secure, it is essential to follow a database security checklist.

Securing a MySQL Database Server is essential for any organization. Without proper security measures, the data stored in the database can be vulnerable to malicious attacks and data breaches.

This checklist will provide you with 7 essential best practices that you should follow in order to protect your databases from potential threats. These best practices include steps such as encrypting your databases, monitoring user access, and implementing strong and encrypted password. By following these steps, you can be sure that your databases are safe and secure from malicious attacks.

1. Encrypt Your MySQL/MariaDB Databases and Encrypt all sensitive data.

2. Monitor user access to the MySQL/MariaDB databases and take corrective action if necessary

3. Implement MySQL/MariaDB passwords management policy

4. Audit the security of the MySQL/MariaDB server by using a tool called MySAT

5. Monitor MySQL/MariaDB database operating system for malware and back-door activity.

6. Remove unnecessary software and services in MySQL/MariaDB database operating system.

See also  MySQL database server User Account Types

7. Properly configure firewall rules to deny access in case of a breach. Limit only trusted source to access MySQL/MariaDB database server.

Start at basic steps : Secure your MySQL/MariaDB server with The Secure MySQL Installer

The mysql-server package comes pre-configured with a utility called mysql_secure_installation that is used to set up a secure starting point for MySQL server, by deleting anonymous users and allowing you to specify the desired password strength policy.

mysql_secure_installation is a shell script available on Unix systems, and enables you to improve the security of your MariaDB installation in the following ways:

  • You can set a password for root accounts.
  • You can remove root accounts that are accessible from outside the local host.
  • You can remove anonymous-user accounts.
  • You can remove the test database, which by default can be accessed by anonymous users.

Example :

# /usr/bin/mysql_secure_installation

Example of output :

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Conclusion

Data security is a critical aspect of any business, and it’s essential to ensure that your data is safe and secure from potential threats. Fortunately, there are a number of practices that organizations can implement today to protect their data and keep it secure. From encrypting data to using multi-factor authentication, these practices can help to ensure the safety of your data. By implementing these practices now, businesses can be sure that their data is protected from potential threats in the future.

Leave a Comment