How to Install MariaDB on Arch Linux

This guide will demonstrate how to install MariaDB on Arch Linux utilizing the command-line terminal.

MariaDB stands as a robust and versatile open-source relational database management system, widely recognized for its reliability, performance, and compatibility with MySQL. With a focus on providing a scalable, secure database environment, MariaDB offers a comprehensive suite of features that cater to the needs of modern applications. Notably, its storage-engine versatility allows for fine-tuning database performance and flexibility, making it a preferred choice for developers and database administrators alike.

Here are the key technical highlights that set MariaDB:

  • Open-source Flexibility: Offers full transparency and benefits from contributions by a global development community.
  • MySQL Compatibility: Ensures easy migration and seamless operation for MySQL users with full SQL and API compatibility.
  • Advanced Replication Techniques: Supports both synchronous and asynchronous replication, enhancing data availability and read scalability.
  • Comprehensive Security Measures: Includes robust security features like role-based access control and data encryption to protect sensitive information.
  • Versatile Storage Engines: Provides a selection of storage engines (InnoDB, Aria, MyRocks) to optimize for various performance and storage needs.
  • Optimized Query Performance: Features an advanced query optimizer and custom storage solutions aimed at delivering high-speed data access.
  • Broad Platform Support: Can be deployed across numerous operating systems, ensuring flexibility in different IT environments.
  • Rich Tooling Ecosystem: Comes equipped with a variety of tools and plugins for backup, monitoring, and analysis, simplifying database management and optimization.

MariaDB’s blend of performance, ease of use, and flexibility makes it an exemplary database solution for both small projects and large enterprise applications. It continuously evolves to meet the demands of modern data processing challenges, all while maintaining a strong commitment to open-source principles.

Now, let’s move forward to how you can leverage these capabilities by installing MariaDB on your Arch Linux system.

Update Arch Linux Before MariaDB Installation

Initiating the MariaDB installation necessitates an up-to-date Arch Linux system. This preliminary step ensures the system is fortified with the latest security patches and software versions, providing a stable environment for subsequent installations:

sudo pacman -Syu

Executing the above command, sudo pacman -Syu, prompts the system to synchronize the package database and update all installed packages, safeguarding against potential vulnerabilities and ensuring compatibility with the MariaDB installation.

Install MariaDB on Arch Linux via Pacman Command

Next, run the following command to install MariaDB on Arch Linux utilizing the pacman package manager and Arch Linux repository:

sudo pacman -S mariadb

Upon executing sudo pacman -S mariadb, the system may request confirmation to proceed with the installation. After the installation, initializing the MariaDB database is paramount, executed with the following command:

sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Example output:

Screenshot showcasing the installation and database initialization of MariaDB on Arch Linux.
Step-by-step through the installation and database initialization of MariaDB on Arch Linux, ensuring a secure and stable setup.

Enable MariaDB Service on Arch Linux

Ensuring MariaDB operates seamlessly post-installation involves enabling the service, ensuring its automatic startup upon system boot, and initiating its immediate run the command:

sudo systemctl enable mariadb --now

You can optionally verify the MariaDB installation by checking its version:

mariadb --version

Moreover, to ascertain the operational status of the MariaDB service, utilize the following command:

systemctl status mariadb

Example:

Screenshot displaying the systemd status as OK for MariaDB on Arch Linux.
Systemd status confirming MariaDB is operating correctly and has been successfully started on Arch Linux.

Run MariaDB Security Script on Arch Linux

Securing MariaDB post-installation is paramount to safeguard data and deter unauthorized access. Fresh installations of MariaDB, while robust, may possess default settings that are potentially susceptible to unauthorized exploitations or intrusions. MariaDB provides a security script designed to navigate users through enhancing the security of their installation.

Executing the MariaDB Security Script

Initiate the security script by executing the following command:

sudo mariadb-secure-installation

Throughout the execution of the script, several prompts will appear, each about a specific security enhancement:

  • Defining the Root Password: Establish a robust password for the root user to ensure exclusive access to authorized users.
  • Restricting Remote Root Access: Limit root access strictly to the local host, negating unauthorized remote access.
  • Eliminating Anonymous Users: Purge any anonymous user accounts that may have been instantiated during installation.
  • Deleting the Test Database: Remove the default test database, which anonymous users could potentially access.

Respond with “Y” to each prompt to affirmatively apply the respective security enhancement.

Example Output

Here is an example of how the mariadb-secure-installation script output might look with the appropriate responses:

[joshua@arch-linux ~]$ sudo mariadb-secure-installation

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
haven't set the root password yet, you should just press enter here.

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

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

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y <---- Type Y then press the ENTER KEY.
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y <---- Type Y then press the ENTER KEY.
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 <---- Type Y then press the ENTER KEY.
 ... 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 <---- Type Y then press the ENTER KEY.
 ... 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 <---- Type Y then press the ENTER KEY.
 - 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 <---- Type Y then press the ENTER KEY.
 ... 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!
Screenshot demonstrating the running of a MariaDB security script after installation on Arch Linux.
Ensuring a secure MariaDB setup by executing the provided security script after initial installation on Arch Linux.

Step 5: MariaDB Database Tables Upgrade Tool

In instances where you’ve performed an upgrade from a previous MariaDB version, you must verify your database tables’ compatibility and fix any issues that emerged during the upgrade. MariaDB provides a specialized tool, the MariaDB Database Tables Upgrade Tool, to ease this process.

Engaging the MariaDB Database Tables Upgrade Tool

To deploy the MariaDB Database Tables Upgrade Tool and ensure the optimal condition of your database tables, employ the following command:

sudo mariadb-upgrade

Example output (the database was already updated):

Screenshot illustrating the execution of the mariadb-upgrade command on Arch Linux.
Upgrade your MariaDB installation securely with the mariadb-upgrade command, demonstrated on Arch Linux.

Additional Commands for MariaDB on Arch Linux

Remove MariaDB from Your Arch Linux System

In specific scenarios, you might find that MariaDB no longer aligns with your project needs or system requirements on your Arch Linux. Should you decide to uninstall it, the following steps will guide you through a clean and complete removal process.

Executing MariaDB Uninstallation

To uninstall MariaDB and concurrently manage the removal of most unused dependencies related to its installation, utilize the following command:

sudo pacman -R mariadb

Executing this command will remove MariaDB and help maintain a clean system by eliminating its associated components. This ensures your Arch Linux system stays organized without unnecessary files and configurations.

Conclusion

In wrapping up our guide, we’ve walked through the steps to successfully install MariaDB on Arch Linux, ensuring you’re equipped to leverage this powerful database system on your setup. Our journey emphasized simplicity and clarity, aiming to make the process as straightforward as possible. A final piece of advice: keep your MariaDB installation up to date to benefit from the latest features and security enhancements. Remember, staying current with your software versions, especially on a rolling release distro like Arch Linux, is key to maintaining a secure and efficient system. Here’s to managing your data more effectively and exploring the full potential of MariaDB on your Arch Linux system. Happy database managing!

Leave a Comment