How to Install MySQL 8 on Ubuntu 23.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 23.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: Add MySQL APT Repository

The default Ubuntu 23.04 repository does not have MySQL 8. To install MySQL 8, you need to add the MySQL APT repository.

Download and add the MySQL APT repository by running the following commands:

		sudo wget https://dev.mysql.com/get/mysql-apt-config_0.8.17-1_all.deb
		sudo dpkg -i mysql-apt-config_0.8.17-1_all.deb
	

During the installation process, you will be prompted to choose the MySQL version and other settings. Select MySQL Server 8.0 and Ubuntu 23.04.

Step 3: Install MySQL 8

Now that the MySQL APT repository has been added, you can install MySQL 8 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 4: 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 5: 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 6: 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 23.04. With MySQL installed, you can start building powerful and scalable web applications that can handle a large amount of data.