Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

How to install MySQL 8 on Ubuntu 22.04

Hello, friends. In this post, you will learn how to install MySQL 8 on Ubuntu 22.04. This post is for newbies, but it is always good to have it handy for everyone.

MySQL: Introduction

MySQL is a powerful relational database manager owned by Oracle. It is open source but also has dedicated enterprise support, which makes it a great alternative to other paid solutions.

Written in C and C++ it is capable of being very fast and handling many requests per second. This makes it suitable for projects of all types and sizes.

In addition to this, MySQL becomes an important tool for many developers who have it for environment testing.

Let’s get to it.

Install MySQL on Ubuntu 22.04

- Advertisement -

Fortunately, MySQL is present in the official Ubuntu repositories, so everything has been simplified.

So, open a terminal and update the whole operating system

sudo apt update
sudo apt upgrade

Once the system is upgraded, you can install MySQL from the official repositories-

sudo apt install mysql-server
Install MySQL 8 on Ubuntu 22.04 | Linux Mint 21
Install MySQL 8 on Ubuntu 22.04 | Linux Mint 21
- Advertisement -

Thereafter, you can check the MySQL version.

mysql --version

Sample Output:

mysql Ver 8.0.30-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))

Now check the status of the service:

systemctl status mysql
MySQL status
MySQL status

So, all this indicates that MySQL is running and installed correctly.

Configuring MySQL before using it

By default, MySQL does not set the root password and some extra settings need to be made.

To achieve this, run this script

sudo mysql_secure_installation

And there you can, first, choose the password strength level

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 

Then, set the password:

Please set the password for root here.
New password:
Re-enter new password: 

After this, configure MySQL before using it by answering the configuration questions:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

With this, you will be able to use MySQL.

sudo mysql -u root -p

And you are done.

Conclusion

Thanks to this post, you learned how to take the first steps with MySQL. I hope you liked it.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook