MySQL is a fast, open-source relational database system used to store, manage, and retrieve structured data developed by Oracle. It stores data in tables organized by rows and columns and uses Structured Query Language (SQL) to manage and access that data.
MySQL is known for being fast, reliable, and easy to use, making it one of the most popular databases for web applications, mobile apps, and enterprise software. It supports a variety of storage engines, offers replication features for scaling and high availability, and ensures data integrity with ACID-compliant transactions.
In this tutorial, we will show you how to install MySQL 8.4 on a Ubuntu 24.04 OS.
Update Operating System
Update your Ubuntu 24.04 operating system to make sure all existing packages are up to date:
# apt update && apt upgrade -y
Add MySQL 8.4 Repository
MySQL 8.0 is the currently available version on the default Ubuntu 24.04 repositories.
Go to the download page for the MySQL 8.4 APT repository.
Also you can run the following command to download it to your Ubuntu 24.04 system:
# wget https://dev.mysql.com/get/mysql-apt-config_0.8.34-1_all.deb
Now install the downloaded .deb package with the following command:
# dpkg -i mysql-apt-config_0.8.34-1_all.deb
During the installation of the package, you will be asked to choose the versions of the MySQL server and other components that you want to install. Choose Ok to finish the configuration and installation of the release package.
Once you are done, update the repository with the following command:
# apt-get update
To check if MySQL 8.4 repo has been successfully installed run the following command:
# apt-cache policy mysql-server
Output:
mysql-server:
Installed: (none)
Candidate: 8.4.5-1ubuntu24.04
Version table:
8.4.5-1ubuntu24.04 500
500 http://repo.mysql.com/apt/ubuntu noble/mysql-8.4-lts amd64 Packages
8.0.41-0ubuntu0.24.04.1 500
500 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu noble-security/main amd64 Packages
8.0.36-2ubuntu3 500
500 http://archive.ubuntu.com/ubuntu noble/main amd64 Packages
Install MySQL 8.4 on Ubuntu 24.04
Now you are ready to install MySQL 8.4 with the following command:
# apt install mysql-server
You will be asked to set root password, you may go ahead and set one.
Then you can verify the installed version of MySQL
with the following command:
# mysql --version
Output:
mysql Ver 8.4.5 for Linux on x86_64 (MySQL Community Server - GPL)
Start the database server daemon, and also enable it to start automatically at the next boot with the following commands:
# systemctl start mysql
# systemctl enable mysql
Check the status of the service:
# systemctl status mysql
Example output:
● mysql.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 5331 (mysqld)
Status: "Server is operational"
Tasks: 35 (limit: 2217)
Memory: 433.7M (peak: 449.8M)
CPU: 2.315s
CGroup: /system.slice/mysql.service
└─5331 /usr/sbin/mysqld
MySQL Create Database
We need to login to MySQL
shell with the following command:
# mysql -u root -p
To create a database in MySQL
you need to run the following command:
mysql> CREATE DATABASE your_db;
View the new database:
SHOW DATABASES;
To create a new MySQL
user, run the following command:
mysql> CREATE USER 'your_user'@localhost IDENTIFIED BY 'password';
Note: You should replace password
with a secure password.
Give the user full rights to the new database:
GRANT ALL PRIVILEGES ON your_db.* TO 'your_user'@'localhost';
Refresh privileges so they take effect:
FLUSH PRIVILEGES;
Exit the MySQL
shell:
mysql> exit
Comments and Conclusion
That’s it. You have successfully installed MySQL 8.4
on Ubuntu 24.04.
For additional help or useful information, we recommend you to check the official MySQL documentation.
If you have any questions please leave a comment below.