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.
Before starting the installation, make sure to update your OS system first.
sudo apt update
Then install MariaDB server using the following command
sudo apt install mariadb-server
Wait until the installation process is complete. Then to check whether MariaDB is running, check with the following command
sudo systemctl status mariadb
After MariaDB has been successfully installed, the next step is to configure MariaDB. Run the following command
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
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
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
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
At this point, it means that MariaDB has been successfully configured.
To access, you can use the following command
mysql -u root -p
To create a view of all databases with the following command
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;
For an example, see the following image
Good luck 🙂