How To Install MySQL on Ubuntu

How To Install MySQL on Ubuntu 24- Quick Tutorial 2025

When it comes to installing MySQL on Ubuntu for relational database management systems is a crucial step in setting up a web application stack. This guide will walk you through the process of how to install MySQL on Ubuntu.

Prerequisites to Install MySQL on Ubuntu 24

  • VPS: Get Powerful VPS Hosting: Visit HostBet.in
  • Access to your VPS: You should have the IP address and password provided by HostBet. (Once you purchase a VPS hosting plan from any VPS hosting provider, you’ll typically receive an email with the IP address, password, and other details:)
  • SSH client: A tool like PuTTY or Terminal (on macOS/Linux) to connect to your VPS. How to Connect to Your VPS Hosting via SSH/PuTTY 

Remember that before installing any components, such as Linux, Apache, MySQL, or PHP, always start by updating your package index to ensure you are getting the latest version of MySQL.

Update Package Lists

To update packages, you need to ensure you have the latest packages. If not, then you run the following command: 

Install MySQL Server

Next, install the MySQL server package.

Secure the Installation

Once the installation is complete, run the script to improve your MySQL installation’s security.

Once you enter this command in the terminal, sudo mysql_secure_installation, you will see the prompt.

To secure your MySQL installations,  you need to follow the prompts during the mysql_secure_installation script. 1. Create a strong root password; 2. Remove anonymous users; 3. Disable remote root login; 4. Delete the test database. Answering “yes” to all prompts is generally recommended for optimal security.

Check MySQL Service

Ensure MySQL service is running.

Basically, this command is used to verify the status of your MySQL services; that means you can easily verify the status if your MySQL is running, stopped, or has encountered any errors.

Log into MySQL

To manage your MySQL database, log in to the MySQL root user.

You must enter the root password you set up earlier.

Create a Database

After logging in, you can easily create your first database.

Replace your_database_name with the desired name for your database.

Create a New User

It’s good for practice for creating new users and granting necessary privileges. 

Exit MySQL

Once you’re done, exit the MySQL shell.

Final Thought on Install MySQL on Ubuntu

Following these steps will give you a fully functional MySQL server on your Ubuntu! Now you can easily create a database, users, and tables for developing websites and applications running a production server.

Scroll to Top