DEV Community

Ngobrolin IT
Ngobrolin IT

Posted on

5

How to Install MySQL / MariaDB on Linux Ubuntu

Hello, dev.. ๐Ÿ‘‹

In this tutorial, I want to share how to install MySQL or MariaDB on Linux Ubuntu. The Linux Iโ€™m currently using is Ubuntu 22.04 LTS, so if your Linux OS is the same, you can follow this tutorial.

MySQL / MariaDB

In this tutorial, we will install MariaDB, but you need to know that MariaDB and MySQL are similar. Because MariaDB is a development of the free and open-source version of MySQL after MySQL was acquired by the Oracle company. MariaDB was developed by the original MySQL developer. In terms of performance, MariaDB is faster and more efficient than MySQL.

Install MariaDB

Before starting the installation, make sure to update your OS system first.

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Then install MariaDB server using the following command

sudo apt install mariadb-server
Enter fullscreen mode Exit fullscreen mode

Wait until the installation process is complete. Then to check whether MariaDB is running, check with the following command

sudo systemctl status mariadb
Enter fullscreen mode Exit fullscreen mode

MariaDB Configuration

After MariaDB has been successfully installed, the next step is to configure MariaDB. Run the following command

sudo mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode

Then when Enter current password for root (enter for none) appears: just click enter, because we havenโ€™t set a password yet.

Then the question appears Change the root password? [Y/n] Letโ€™s just choose Y. We will change the root account password. Type a new password and retype the new password. So the result is like this.

Change the root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
... Success!
Enter fullscreen mode Exit fullscreen mode

Continue the process until reloading privileges.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... 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!
Enter fullscreen mode Exit fullscreen mode

At this point, it means that MariaDB has been successfully configured.

MariaDB Access

To access, you can use the following command

mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

To create a view of all databases with the following command

show databases;
Enter fullscreen mode Exit fullscreen mode

Donโ€™t forget the semicolon if you access using the MariaDB command line.

Then to create a database use the following command

create database database_name;
Enter fullscreen mode Exit fullscreen mode

For an example, see the following image

MariaDB Ubuntu 22.04

Good luck ๐Ÿป

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

๐Ÿ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay