How to install mariadb on ubuntu 22. 04

How to Install MariaDB on Ubuntu 22.04

MariaDB is a freely available and open-source database. MariaDB was initially developed in 2010 when Oracle bought MySQL, and MySQL developers thought that MySQL would now be updated as a paid service. So, they wanted to create a database that was going to be free and open source and has employed MySQL strategies in it.

This blog will demonstrate the method to install, use, and uninstall MariaDB on Ubuntu 22.04. Let’s get started!

How to install MariaDB on Ubuntu 22.04

For the purpose of installing MariaDB on Ubuntu 22.04, follow the given instructions.

Step 1: Update system packages
First of all, update the system packages by hitting “CTRL+ALT+T

Sponsored
and running provided command:

$ sudo apt update

All packages are updated:

Step 2: Install packages
Execute the below-given command to install packages essential for MariaDB installation:

$ sudo apt-get install wget software-properties-common dirmngr ca-certificates apt-transport-https -y

Now move to the next step.

Step 3: Install MariaDB
To install MariaDB on Ubuntu 22.04, utilize the given command in the terminal:

$ sudo apt install mariadb-server mariadb-client

MariaDB installation will take a few minutes to complete:

Step 4: Check MariaDB version
Now, check the version of the installed MariaDB:

$ mariadb –version

The given output indicates that we have successfully installed MariaDB version “15.1” on our Ubuntu 22.04:

Step 5: Check MariaDB status
Then, check if MariaDB is active on your Ubuntu 22.04 system:

$ systemctl status mariadb

As you can see, MariaDB is currently active and running on our system:

Step 6: Execute MariaDB script
In this step, we will install the security script with the MariaDB installation to protect our database from hacker and any kind of intrusion:

$ sudo mysql_secure_installation

You will be then asked to configure the following settings:

  • Password for root user
  • unix-socket authentication
  • Test database and its access
  • Reloading privileges

Type out “Y” for “yes” and “n” for refusing the given option:

Step 7: Log in to MariaDB
Write out the provided command in terminal for logging in to MariaDB account:

$ sudo mariadb

Step 8: Flush privileges
Before moving ahead firstly, it is required to flush all privileges:

> flush privileges;

Step 9: Create database
Then create the Maria database by utilizing the given command:

> CREATE DATABASE testdb;

In our case, We have named our database as “testdb”:

Step 10: View Database
To view the list of newly created and existing Maria Databases, execute the provided command:

> SHOW DATABASES;

Step 11: Create MariaDB user
In the next step, specify the username and password in the below-given command for creating a MariaDB user:

> CREATE USER ‘linuxhint’@‘localhost’ IDENTIFIED BY ‘new_password’;

Step 12: Grant Privileges
Then grant all privileges to the created MariaDB “linuxhint” user:

> GRANT ALL PRIVILEGES ON *.* to ‘linuxhint’@‘localhost’;

Step 13: Exit MariaDB
Lastly, type “quit” to logout from the active MariaDB shell:

> quit;

Want to upgrade MariaDB? Have a look at the following section.

How to upgrade MariaDB on Ubuntu 22.04

In order to upgrade the version of installed MariaDB, write out the provided command in the terminal:

$ sudo mariadb-upgrade

Now, let’s check the procedure for uninstalling MariaDB from Ubuntu 22.04.

How to uninstall MariaDB on Ubuntu 22.04

To uninstall MariaDB, type the provided command in the Ubuntu 22.04 terminal:

$ sudo apt autoremove mariadb-server mariadb-client –purge -y

Hit the “yes” option to make sure that you want to delete all MariaDB databases:

The given output indicates that MariaDB is successfully removed from our Ubuntu 22.04 system:

We have compiled the easiest method to install, use, and uninstall MariaDB on Ubuntu 22.04 system.

Conclusion

To install MariaDB on Ubuntu 22.04, firstly, update the system packages. After that, install the required packages and run the “$ sudo apt install mariadb-server mariadb-client” command. Next, execute the security script. Then log in to MariaDB with “$ sudo mariadb” command and create databases, and new users, assign privileges, and use them. This blog demonstrated the method to install, use, and uninstall MariaDB on Ubuntu 22.04.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply