How to Install MySQL 8.0 on Ubuntu 24.04
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.
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.
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
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.
sudo apt update
sudo apt upgrade
Then, run the command below to install it .
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
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.
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.
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.
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.
sudo apt update
sudo apt install mysql-community-server
Leave it blank to enable passwordless login using UNIX socket based authentication.


Once installed, you can use the commands below to start, stop, enable, restart, or disable MySQL service.
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.
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.
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?
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.
No comments yet — be the first to share your thoughts!