How to Install MySQL 8 on Ubuntu 22.04
By FeRuM • April 11, 2023
MySQL is a popular open-source relational database management system used by many web applications. In this tutorial, we will walk through the steps to install MySQL 8 on Ubuntu 22.04.
Step 1: Update the system
Before installing MySQL, make sure your system is up-to-date. You can do this by running the following commands:
sudo apt update sudo apt upgrade
Step 2: Install MySQL 8
MySQL 8 is available in the default Ubuntu 22.04 repository. You can install it by running the following command:
sudo apt install mysql-server
During the installation process, you will be prompted to set a password for the MySQL root user.
Step 3: Configure MySQL
After installing MySQL, you should run the security script included with the software:
sudo mysql_secure_installation
This script will guide you through several configuration options, including setting a new root password, removing anonymous users, and disabling remote root login.
Step 4: Verify MySQL installation
You can verify that MySQL is installed and running properly by typing the following command:
systemctl status mysql.service
If MySQL is running, you will see output similar to the following:
mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2023-04-09 19:33:15 UTC; 2 days ago
Step 5: Connect to MySQL
You can connect to the MySQL server using the mysql client:
mysql -u root -p
This will prompt you for the root password you set during installation. Once authenticated, you will have access to the MySQL command-line interface.
Conclusion
Now you know how to install and configure MySQL 8 on Ubuntu 22.04. With MySQL installed, you can start building powerful and scalable web applications that can handle a large amount of data.