How to Install MySQL on Ubuntu 24.04: Quick Guide

Wondering about how to install MySQL on Ubuntu 24.04? Go through this post then!

How to Install MySQL on Ubuntu 24.04?

MySQL is an open-source RDBMS available for Linux distributions, including Debian, and Ubuntu.

Let’s get it on Ubuntu 24.04.

Step 1: Update the System

Update the system through the mentioned command:

sudo apt update
updating packages in ubuntu 24.04

Step 2: Install MySQL Server

Next, we need to install “mysql-server“:

sudo apt install mysql-server
installing mysql server on ubuntu 24.04

Step 3: Check the MySQL version

To validate the MySQL installation, check its version:

mysqld --version
checking mysql version on ubuntu 24.04

Step 4: Check MySQL Service Status

Once installed, check MySQL service status with the help of the below command:

sudo systemctl status mysql
checking mysql status in ubuntu 24.04

Step 5: Start MySQL Service

If MySQL service is not started yet, you can start it via:

sudo systemctl start mysql.service

Step 6: Secure MySQL Installation

Execute the given command to enhance MySQL server security:

sudo mysql_secure_installation
securing mysql installation on ubuntu 24.04

Next, enable VALIDATE PASSWORD COMPONENT to check the strength of the user password:

validating password component for mysql in ubuntu 24.04

Now, select the minimum password strength as per your preferences:

viewing three levels of password validation policy of mysql in ubuntu 24.04

In our case, we selected “Strong” as the required password’s strength:

setting storing password option for mysql in ubuntu 24.04

Next, remove anonymous users:

removing anonymous user from ubuntu 24.04

Then, disallow root to login remotely:

disallowing root login remotely in ubuntu 24.04

After that, remove the test database and access to it:

removing test database and its access in ubuntu 24.04

Lastly, enter “y” to reload privilege tables:

reloading privilege tables in ubuntu 24.04

Step 7: Login to MySQL Server

Once all is done, log in to the MySQL server via:

sudo mysql -u root
login to mysql as root in ubuntu 24.04

Leave a Comment

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

Scroll to Top