Cybersecurity Updates & Tools

How to Install and Secure MySQL on Ubuntu 26.04

If you want to Install MySQL Ubuntu systems for web applications, development environments, or database hosting, Ubuntu 26.04 offers a fast and reliable setup process. MySQL remains one of the most trusted open-source relational database systems used in modern Linux infrastructures.

This guide explains how to install MySQL 8.4 on Ubuntu 26.04, secure the server, create databases, and enable remote access safely.

Why Choose MySQL on Ubuntu 26.04?

MySQL is widely used in LAMP and LEMP stacks because it delivers excellent performance, scalability, and stability. Developers often pair it with PHP, Apache, or Nginx for hosting websites and enterprise applications.

Ubuntu 26.04 ships with MySQL 8.4 directly from its official repositories, making installation simple and secure.

Install MySQL Ubuntu Server

Before starting, ensure your account has sudo privileges.

First, refresh the package index:

sudo apt update

Next, install the MySQL server package:

sudo apt install mysql-server

Once installation finishes, the MySQL service starts automatically. Verify the service status with:

sudo systemctl status mysql

You should see the service marked as active and running.

To confirm the installed version, run:

mysql --version

This command displays the MySQL release currently installed on your Ubuntu system.

Secure Install MySQL Ubuntu Environment

After installation, securing the database server is extremely important. MySQL includes a built-in security script that helps remove unsafe defaults.

Run the following command:

sudo mysql_secure_installation

During the setup process, you can:

  • Enable password validation
  • Remove anonymous users
  • Disable remote root logins
  • Delete test databases
  • Reload privilege tables

For production servers, selecting at least the MEDIUM password policy is recommended.

Create MySQL Database and User

After securing the server, you can create databases and dedicated user accounts.

Open the MySQL shell:

sudo mysql

Create a new database:

CREATE DATABASE myapp;

Now create a new user and assign permissions:

CREATE USER 'myappuser'@'localhost' IDENTIFIED BY 'strong_password';GRANT ALL PRIVILEGES ON myapp.* TO 'myappuser'@'localhost';FLUSH PRIVILEGES;

Using separate accounts instead of the root user improves overall security.

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

Locate the bind-address setting and update it:

bind-address = 0.0.0.0

Restart MySQL afterward:

sudo systemctl restart mysql

You should also allow port 3306 through the firewall for trusted IP addresses only:

sudo ufw allow from 192.168.1.100 to any port 3306

Avoid exposing MySQL publicly unless absolutely necessary.

Conclusion

Learning how to Install MySQL Ubuntu servers correctly is essential for building secure and scalable Linux hosting environments. Ubuntu 26.04 simplifies the deployment process while MySQL 8.4 provides modern authentication, strong performance, and enterprise-ready features.

After completing the setup, you can continue by integrating MySQL with PHP, WordPress, Laravel, or containerized applications for production workloads.