How to Install MariaDB on Ubuntu 22.04

To install MariaDB on Ubuntu 22.04, you can follow these steps. MariaDB is a popular relational database management system, and it can be easily installed using the package manager. Here's a guide:

Step 1 : Update Package List

Before installing any new packages, it's a good practice to update the package list:

Step 2 : Install MariaDB Server

You can install the MariaDB server package using the following command:

Step 3 : Secure MariaDB Installation

Run the MariaDB security script to enhance the security of your installation:

Follow these steps during the script execution:

- Enter the root password you set during installation. If you didn't set a password during installation, press Enter

- Choose whether to set up the VALIDATE PASSWORD plugin. This plugin checks password strength. Select 'Y' for Yes or 'N' for No.

- Choose the password strength level that suits your security preferences.

- Decide whether to remove anonymous users ('Y' for Yes, 'N' for No).

- Choose whether to disallow remote root login ('Y' for Yes, 'N' for No).

- Decide whether to remove the test database and access to it ('Y' for Yes, 'N' for No).

- Choose 'Y' to reload the privilege tables.

The MariaDB server is now secured based on your responses.

Step 4 : Start and Enable MariaDB Service

After installation, start the MariaDB service and enable it to start on boot:

Step 5 : Verify MariaDB Installation

You can verify the installation by logging into the MariaDB server:

Step 6 : Create a New User

- Log in to the MariaDB server with the root account:

- Create a new user and set a password (replace your_user and your_password with your chosen username and password):

- Grant all privileges to the user.

- Flush the privileges to apply the changes:

- Exit the MariaDB prompt:

Step 7 : Test the New User

Log in to MariaDB using the newly created user to ensure it has the necessary privileges:

Enter the user's password when prompted.

Congratulations! You've now installed MariaDB on Ubuntu 22.04. You can start creating databases, tables, and users as needed for your applications.