
MariaDB is an open-source relational database management system built as a drop-in replacement for MySQL. It offers improved performance, additional storage engines, and enhanced security features while maintaining full compatibility with MySQL syntax and tools. MariaDB is commonly used in web application stacks, data analytics platforms, and enterprise environments.
This article explains how to install MariaDB on an Ubuntu 26.04 server. It covers the database server setup, service management, security hardening, and basic database operations including user creation and privilege management.
Before you begin, you need to:
The default Ubuntu 26.04 APT repositories include the MariaDB server package. The following steps install the database server and verify the service status.
Update the APT package index.
Install the MariaDB server package.
Confirm the installed MariaDB version.
Your output should be similar to the one below:
Enable MariaDB to start automatically at boot time.
Start the MariaDB service.
Verify that MariaDB is active and running.
The output should display active (running), confirming that the MariaDB server is operational.
A default MariaDB installation allows the root user to access the database console without a password. The mysql_secure_installation script assigns a root password, removes anonymous accounts, disables remote root login, and drops the test database.
Run the MariaDB security script.
Respond to each prompt as described below:
Restart MariaDB to apply the new security settings.
The mariadb command-line client provides direct access to the database console. It is also compatible with the mysql command and graphical tools such as phpMyAdmin. The following steps log in as the root user, create a database, and configure a dedicated user with appropriate privileges.
Log in to the MariaDB console as the root user.
Enter the root password you configured in the previous section.
Create a new database named example_db.
Verify that the database exists.
Your output should be similar to the one below:
Create a database user named example_user with a strong password. Replace strong_password with your desired password.
Grant the user full privileges on the example_db database.
Reload the privilege tables to activate the new user permissions.
Exit the MariaDB console.
The example_user account has the privileges required to create and manage tables within the example_db database. The following steps log in as that user, create a table, insert sample records, and query the data.
Log in to MariaDB as the example_user.
Enter the example_user password when prompted.
Switch to the example_db database.
Create a table named employees with columns for an auto-incrementing ID, a name, a department, and a hire date.
Insert sample records into the employees table.
Query the table to verify the inserted data.
Your output should be similar to the one below:
Exit the MariaDB console.
You have installed and secured MariaDB on an Ubuntu 26.04 server, configured password-based authentication, and created a dedicated database user. MariaDB integrates with web application stacks such as LAMP and LEMP, and supports replication for high-availability deployments. For more information, refer to the official MariaDB documentation.
0 Comments
Be the first to comment and share your perspective with the community.