How To

Install MySQL Ubuntu 24.04 for Secure Database Setup

If you want to Install MySQL Ubuntu servers for web applications, development, or database hosting, Ubuntu 24.04 offers a fast and reliable setup process. MySQL remains one of the most trusted relational database systems because of its speed, scalability, and compatibility with modern applications.

This guide walks through installing MySQL 8.0 on Ubuntu 24.04, securing the database server, creating users, and enabling remote access safely.

Why Install MySQL Ubuntu Servers?

MySQL powers thousands of websites and enterprise applications worldwide. It integrates perfectly with Linux-based hosting environments like LAMP and LEMP stacks.

Ubuntu 24.04 includes MySQL 8.0 in its official repositories, making installation straightforward without downloading external packages.

Whether you are deploying WordPress, Laravel, or custom applications, MySQL delivers reliable performance and easy database management.

Install MySQL Ubuntu 24.04

Start by updating your package index:

sudo apt update

Next, install the MySQL server package:

sudo apt install mysql-server

After installation, verify that the MySQL service is running correctly:

sudo systemctl status mysql

You should see the service marked as active and enabled.

To check the installed version, run:

mysql --version

This confirms that MySQL 8.0 is successfully installed on Ubuntu 24.04.

Secure Install MySQL Ubuntu Systems

After installation, securing the database server is highly recommended. MySQL provides a built-in hardening script for this purpose.

Run:

sudo mysql_secure_installation

The script helps you:

  • Set password validation rules
  • Remove anonymous accounts
  • Disable remote root login
  • Delete test databases
  • Reload security privileges

Choose strong password policies whenever possible to improve server protection.

Logging Into MySQL

Ubuntu configures MySQL root authentication using the auth_socket plugin by default. This means you can access MySQL using sudo without entering a separate root password.

Log in with:

sudo mysql

Once inside the MySQL shell, you can manage databases, users, and permissions directly.

Exit the shell using:

exit;

Create a Database and User

For security reasons, avoid using the root account for applications.

Create a new database:

CREATE DATABASE myapp;

Create a dedicated user:

CREATE USER 'myappuser'@'localhost' IDENTIFIED BY 'strong_password';

Grant permissions:

GRANT ALL PRIVILEGES ON myapp.* TO 'myappuser'@'localhost';FLUSH PRIVILEGES;

This approach improves database security and keeps application access isolated.

Enable Remote Access Securely

By default, MySQL only accepts local connections. If remote access is required, edit the MySQL configuration file:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Update the bind address:

bind-address = 0.0.0.0

Restart MySQL afterward:

sudo systemctl restart mysql

Allow MySQL traffic through the firewall:

sudo ufw allow 3306/tcp

However, avoid exposing MySQL publicly unless absolutely necessary. Restrict access to trusted IP addresses whenever possible.

Conclusion

Learning how to Install MySQL Ubuntu systems is essential for developers, administrators, and hosting environments. Ubuntu 24.04 simplifies the process with official repositories, secure defaults, and reliable package management.

After installation, remember to secure the server, create dedicated users, and carefully manage remote access to maintain a safe and stable database environment.

Cyber Defence

Recent Posts

Install Pip on Ubuntu 18.04: Python 3 and Python 2 Setup Guide

Pip is the official package manager for Python and the standard way to install libraries from…

20 hours ago

Install R on Ubuntu 18.04 from CRAN: Statistical Computing Setup

R is an open-source programming language and environment built for statistical computing and data visualization. It…

20 hours ago

Install Jenkins on Ubuntu 18.04: CI/CD Server Setup Guide

Jenkins is an open-source automation server that makes it easy to build CI/CD pipelines. Continuous integration…

20 hours ago

Install Android Studio on Ubuntu 18.04 with Snap and OpenJDK 8

Android Studio is the official IDE for Android development, built on JetBrains' IntelliJ IDEA platform. It…

20 hours ago

Install and Configure GitLab on Ubuntu 18.04 with Omnibus

GitLab is a web-based, open-source Git repository manager written in Ruby. It includes built-in tools for…

20 hours ago

Install Anaconda on Ubuntu 18.04: Python Data Science Setup Guide

Anaconda is the most widely used Python distribution for data science and machine learning. It bundles…

2 days ago