Support Online
Skip to main content

MariaDB Installation: Power Up Your Ubuntu 22.04 Server

🚀 What Will You Learn in This Guide?

This guide teaches you how to install and securely configure the MariaDB database on your Ubuntu 22.04 server.
By making security settings after installation, you will make the system ready for use immediately.
Optionally, you will also learn how to create a password-based administrator account.

🧠 Technical Summary

Subject: Installation of MariaDB relational database management system on Ubuntu 22.04
Solution: Providing developers with a secure database environment (MySQL alternative)
Steps:

  1. Update package directory
  2. Install MariaDB
  3. Run security script
  4. (Optional) Create user with password
  5. Test service status

⚙️ Step 1 – MariaDB Installation

Ubuntu 22.04 includes the stable MariaDB 10.5.

Update Package Index

sudo apt update

➡️ This command updates the package indexes in the system.

Install MariaDB Server

sudo apt install mariadb-server -y

➡️ This command installs the MariaDB server and necessary utilities.

When the installation is completed, the MariaDB service starts automatically. However, no security configuration has been made.


🔒 Step 2 – Security Configuration

MariaDB can be secured thanks to a script that comes with the installation.

Start Security Script

sudo mysql_secure_installation

➡️ This command configures MariaDB's security settings.

Answer Questions

Root Password: If not, press ENTER.

Type Unix Socket Authentication: n and continue.

Setting Root Password: Type n. Ubuntu handles this automatically.

Remaining Questions: Answer Y (Yes) to all.

These steps:

Removes anonymous users,

Deletes the test database,

Disables remote root access,

Applies security rules immediately.


👨‍💻 Step 3 – (Optional) Creating Administrator User with Password

Since the root account is authenticated with the Unix socket, those who want to use external tools such as phpMyAdmin must create a new user.

Open MariaDB Shell

sudo mariadb

➡️ This command opens the MariaDB shell.

Create New User

GRANT ALL ON *.* TO 'genixnode_admin'@'localhost' IDENTIFIED BY 'gizli_parola' WITH GRANT OPTION;

➡️ This command creates a user with access to all databases.

Apply Powers

FLUSH PRIVILEGES;
exit

➡️ Saves the permissions and logs out.


🧪 Step 4 – Testing the Installation

Check Service Status

sudo systemctl status mariadb

➡️ Indicates whether MariaDB is actively running or not.

If not active:

sudo systemctl start mariadb

Verify Version

sudo mysqladmin version

➡️ Shows MariaDB version and uptime.


💬 Frequently Asked Questions (FAQ)

  1. What is the difference between MariaDB and MySQL?

MariaDB is the open source successor project to MySQL. It updates faster and is community driven.

  1. What is unix_socket authentication?

It is a secure method that allows system users to gain root access without a password.

  1. How do I change my password?
ALTER USER 'genixnode_admin'@'localhost' IDENTIFIED BY 'yeni_parola';
  1. How do I take a database backup?

Mysqldump is recommended for small databases, and Percona XtraBackup is recommended for large ones.

  1. Why won't MariaDB start?

It is usually caused by 3306 port conflict or configuration error. Check the logs with sudo journalctl -xe.


🎯 Result

In this guide, you learned how to install and secure MariaDB on Ubuntu 22.04. Now you can run your own applications in a powerful, secure database environment.