Skip to content
Follow
Ubuntu Linux

How to install MySQL 8.0 on Ubuntu 24.04

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

MySQL 8.0 installs on Ubuntu 24.04 using the Advanced Package Tool (APT), which helps manage software installations.

MySQL 8.0 is a widely used system for managing databases, storing and organizing information that applications need.

For Ubuntu 24.04, you can install it from Ubuntu’s own software sources or get the latest version directly from MySQL’s official website.

This guide shows you the quickest way to get a working MySQL 8.0 server up and running on your system.

⚡ 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

You can install MySQL 8.0 on Ubuntu 24.04 using the system’s built-in APT repositories. This is the easiest method for most people. To start, update your package list with ‘sudo apt update’, then upgrade existing packages using ‘sudo apt upgrade’, and finally install the MySQL server by running ‘sudo apt install mysql-server’.

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

To install the very latest MySQL 8.0 version on Ubuntu 24.04, you can add the official MySQL Community Server repositories. This lets you install directly from MySQL. First, install some needed tools by running ‘sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https curl lsb-release’.

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
⚠️Warning
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
⚠️Warning
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

To completely remove MySQL 8.0 from Ubuntu 24.04, you should stop the service, remove the packages, and delete the configuration files. First, stop the MySQL service by running ‘sudo systemctl stop mysql –now’. Then, remove the server packages using ‘sudo apt autoremove mysql-community-server’ and ‘sudo apt autoremove mysql-server’.

🐧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 Completely Uninstall Docker from Ubuntu
Ubuntu Linux How to Completely Uninstall Docker from Ubuntu
How to Allow Remote Access to MySQL Database on Ubuntu Linux
Ubuntu Linux How to Allow Remote Access to MySQL Database on Ubuntu Linux
How to Reset MySQL or MariaDB Root Password
Ubuntu Linux How to Reset MySQL or MariaDB Root Password

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

Leave a Comment

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