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
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
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
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.