Skip to content
Follow
Ubuntu Linux

How to Install MySQL 8.0 on Ubuntu 24.04

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

MySQL 8.0 is a popular database system that stores and organizes information for websites and apps on your computer. You can install it on Ubuntu 24.04 in 5 steps using the built-in terminal.

Advertisement

The standard Ubuntu software catalog lets you set up the database server fast by running a few short text commands so you can build your projects.

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

Advertisement

Install MySQL 8.0 via Ubuntu APT repositories

Installing MySQL 8.0 via Ubuntu APT repositories is the quickest method to get a database running on Ubuntu 24.04. You just need to update your package list and run the package manager command to download and set up the default server version provided by Ubuntu.

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.

Advertisement

Install MySQL 8.0 with MySQL Community Server

Installing MySQL 8.0 with MySQL Community Server lets you get the newest features directly from the official database developers instead of the Ubuntu package archive. You add the official repository to your system, update your package lists, and install the latest server packages manually.

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.

Advertisement
⬛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
⚠️WarningWhen 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
⚠️WarningSelect 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.

Advertisement
🐧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

Uninstalling MySQL 8.0 completely from Ubuntu 24.04 requires stopping the running database service, removing all server packages, and clearing out leftover configuration files. This process ensures your system is clean if you plan to start a fresh database setup.

🐧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 is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.

Advertisement

📚 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 Root Password on Ubuntu
Ubuntu Linux How to Reset MySQL Root Password on Ubuntu

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

Leave a Comment

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