Follow
Ubuntu Linux

How to install MySQL 8.0 on Ubuntu 24.04

Richard
Written by
Richard
Jul 20, 2024 Updated Mar 20, 2026 3 min read
MySQL featured image
MySQL featured image

You install MySQL 8.0 on Ubuntu 24.04 using the Advanced Package Tool (APT) to manage the installation process.

MySQL 8.0 is a popular open-source relational database management system (RDBMS) that stores and retrieves data for various applications.

For Ubuntu 24.04, you can choose between the version readily available in Ubuntu’s repositories or opt for the newer release directly from the official MySQL APT repository.

This tutorial focuses on the most direct method, ensuring you get a fully functional MySQL 8.0 server running for your projects quickly.

⚡ Quick Answer

Install MySQL 8.0 on Ubuntu 24.04 by updating packages with `sudo apt update && sudo apt upgrade`, then installing the server with `sudo apt install mysql-server`. Alternatively, add the official MySQL repositories for the latest version.

Install MySQL 8.0 via Ubuntu APT repositories

The easiest way to install MySQL is from the default Ubuntu APT repositories. However, the versions in those repositories may not necessarily be the latest.

First, update Ubuntu packages by running the command below.

🐧Bash / Shell
sudo apt update
sudo apt upgrade

Then, run the command below to install it.

🐧Bash / Shell
sudo apt install mysql-server

The command above will install MySQL 8.0 ( the current version as I’m writing this) on Ubuntu 24.04.

Install MySQL 8.0 with MySQL Community Server

Another way to install the latest and most stable version of MySQL 8.0 on Ubuntu is to add its official repositories and install it from there.

First, install some prerequisites by running the command below.

🐧Bash / Shell
sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl lsb-release

Then, run the command below to import its repository GPG key.

💻Code
curl -fsSL http://repo.mysql.com/RPM-GPG-KEY-mysql-2023 | sudo gpg --dearmor | sudo tee /usr/share/keyrings/mysql.gpg > /dev/null

Next, run the command below to add the MySQL 8.0 repository to Ubuntu 24.04.

Command Prompt
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/mysql.gpg] http://repo.mysql.com/apt/ubuntu $(lsb_release -cs) mysql-8.0" | sudo tee -a /etc/apt/sources.list.d/mysql.list

Now that you have successfully added the MySQL 8.0 GPG key and its repositories run the command below to update Ubuntu and install the server.

🐧Bash / Shell
sudo apt update
sudo apt install mysql-community-server

When prompted during the installation, type and confirm a root password. Leave it blank to enable passwordless login using UNIX socket based authentication.

MySQL 8 installation password prompt
MySQL 8 installation password prompt

Select to use a strong password encryption (Recommended) option when prompted.

MySQL 8 installation password prompt strong
MySQL 8 installation password prompt strong

Once installed, you can use the commands below to start, stop, enable, restart, or disable MySQL service.

🐧Bash / Shell
sudo systemctl start mysql
sudo systemctl stop mysql
sudo systemctl enable mysql
sudo systemctl restart mysql
sudo systemctl disable mysql

Run MySQL security script

After installing the MySQL database on Ubuntu, it’s recommended to run its security script to enhance and perform some house cleaning.

🐧Bash / Shell
sudo mysql_secure_installation

Follow the prompts until you’re done.

Uninstall MySQL 8.0

Finally, if you no longer want to use MySQL 8.0 and want to remove it, use the steps below.

🐧Bash / Shell
sudo systemctl stop mysql --now
sudo apt autoremove mysql-community-server
sudo apt autoremove mysql-server
sudo rm /etc/apt/sources.list.d/mysql.list

That should do it!

Conclusion:

  • MySQL 8.0 is a robust and popular open-source relational database management system suitable for various web applications and software.
  • Installing MySQL 8.0 on Ubuntu 24.04 can be accomplished through the default APT repositories or by adding MySQL’s official repositories for the latest stable release.
  • After installation, managing MySQL 8.0 involves starting, stopping, enabling, restarting, or disabling the MySQL service using systemctl commands.
  • Running MySQL’s security script after installation is recommended to enhance security and perform necessary housekeeping.
  • If the need arises to uninstall MySQL 8.0, specific commands can be used to stop, remove, and clean up the installation.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

Backup and Restore MySQL database with mysqldump
Ubuntu Linux Backup and Restore MySQL database with mysqldump
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04
How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *