How to Install MySQL 8 on Ubuntu 25.04 (Step-by-Step Guide for 2025)

How to Install MySQL 8 on Ubuntu 25.04 (Step-by-Step Guide for 2025)

To install   MySQL 8   on   Ubuntu 25.04  , follow these step-by-step instructions :

✅ Step 1: Update Your System

Open your terminal and run :

sudo apt update
sudo apt upgrade -y

✅ Step 2: Install MySQL Server

MySQL 8 is included in the official Ubuntu 25.04 repositories :

sudo apt install mysql-server -y

This will install the latest available MySQL 8.x version.

✅ Step 3: Start & Enable MySQL

Check if MySQL is running :

sudo systemctl status mysql

Enable MySQL to start at boot :

sudo systemctl enable mysql

✅ Step 4: Secure the Installation

Run the built-in security script :

sudo mysql_secure_installation

This will allow you to :

  • Set or change the root password
  • Remove anonymous users
  • Disallow remote root login
  • Remove the test database
  • Reload privilege tables

✅ Step 5: Verify MySQL Installation

Check installed version :

mysql --version

Expected output :

mysql  Ver 8.x.x for Linux on x86_64 (MySQL Community Server - GPL)

✅ Step 6: Log in to MySQL

To log in as root (using the system account) :

sudo mysql

To log in with password :

mysql -u root -p

(If login fails, ensure the root user is configured for password authentication.)

🛠 Optional : Configure Root for Password Login

Run these inside the MySQL shell :

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourSecurePassword';
FLUSH PRIVILEGES;

✅ Done!

You now have   MySQL 8 installed and running   on Ubuntu 25.04.

Tags :