Skip to main content

Step 1: Update the System

Before installing MariaDB, it’s a good practice to update your system’s package list and upgrade existing packages to their latest versions. Open a terminal and run the following commands:

Step 2: Install MariaDB

Once your system is up to date, you can install MariaDB using the package manager. For Ubuntu or Debian-based systems, use the following command:
For CentOS or Red Hat-based systems, use:

Step 3: Secure MariaDB Installation

After installation, it’s crucial to secure your MariaDB installation. Run the following command to start the security script:
Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, remove the test database, and reload the privilege tables.

Step 4: Start and Enable MariaDB Service

To ensure that MariaDB starts automatically at boot, you can enable the service with the following command:
To start the MariaDB service immediately, use:

Step 5: Access MariaDB

You can access the MariaDB server using the MySQL client. To log in as the root user, run:
Enter the root password you set during the secure installation process to access the MariaDB command-line interface.

Step 6: Create a New Database and User (Optional)

If you need to create a new database and user, you can do so using the following SQL commands:
Congratulations! You have successfully set up MariaDB on your Linux Server. You can now start using it to manage your databases.