How to Install MySQL Database Server on Ubuntu Server 22.04: A Step-by-Step Guide

ersinkoc

Ersin KOÇ

Posted on May 14, 2024

How to Install MySQL Database Server on Ubuntu Server 22.04: A Step-by-Step Guide

MySQL is a powerful, open-source relational database management system (RDBMS) that's essential for countless web applications and server-side projects. If you're running an Ubuntu 22.04 server, getting MySQL up and running is surprisingly easy, especially if you're leveraging the lightning-fast NVMe storage on EcoStack Cloud's VPS platform.

Why choose a high-performance VPS for your MySQL database?

  • Blazing-Fast Queries: NVMe storage delivers incredible read/write speeds, significantly reducing the time it takes to retrieve and update data. This translates to snappier application performance and a better user experience.
  • Improved Reliability: EcoStack Cloud's robust infrastructure ensures high uptime and data integrity, so you can trust that your database will be available when you need it.
  • Scalability: As your project grows, you can easily upgrade your VPS resources to accommodate increased database demands.

Prerequisites:

Before we dive in, make sure you have the following:

  • An Ubuntu 22.04 server instance (If you don't have one, spin up a new VPS on EcoStack Cloud in minutes! Our plans start at just €2.90/month).
  • SSH access to your server.
  • Basic familiarity with the Linux terminal.

Installation Steps:

  1. Update Package Repository:

Open your terminal and run the following command to update the package list:

   sudo apt update
Enter fullscreen mode Exit fullscreen mode
  1. Install MySQL Server:

Install the MySQL server package:

   sudo apt install mysql-server
Enter fullscreen mode Exit fullscreen mode

You will be prompted to set a root password during the installation process. Choose a strong password and keep it secure.

  1. Secure Your MySQL Installation (Recommended): Run the security script to improve the security of your MySQL installation:
   sudo mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode

Follow the prompts to set a password validation policy, remove anonymous users, disable remote root login, and remove the test database.

  1. Verify Installation and Start the Service:

Check the status of the MySQL service:

   sudo systemctl status mysql
Enter fullscreen mode Exit fullscreen mode

You should see an output indicating that MySQL is active and running. If it is not running, start the service with:

   sudo systemctl start mysql
Enter fullscreen mode Exit fullscreen mode

You can also enable MySQL to start automatically at boot time:

   sudo systemctl enable mysql
Enter fullscreen mode Exit fullscreen mode

Connecting to MySQL:

Connect to the MySQL server using the following command and enter the root password you set during the installation:

   sudo mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

Conclusion:

Congratulations! You've successfully installed and secured MySQL on your Ubuntu 22.04 server. With EcoStack Cloud's high-performance NVMe storage, your database will run faster and smoother than ever before.

Ready to unlock the full potential of your database-driven applications? Get started with an EcoStack Cloud VPS today and experience the difference! (Starting at just €2.90/month)

💖 💪 🙅 🚩
ersinkoc
Ersin KOÇ

Posted on May 14, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

What was your win this week?
weeklyretro What was your win this week?

November 29, 2024

Where GitOps Meets ClickOps
devops Where GitOps Meets ClickOps

November 29, 2024

How to Use KitOps with MLflow
beginners How to Use KitOps with MLflow

November 29, 2024