Configuring MySQL Server on Ubuntu 20.04 with Security Enhancements

Installing MySQL Server

Execute these commands to instal MySQL on Ubuntu 20.04:

sudo apt update
sudo apt install mysql-server

Verify the installation and check the service status:

mysql --version
sudo systemctl status mysql

Securing MySQL Installation

Run the security script to configure basic security settings:

sudo mysql_secure_installation

This interactive script will guide you through:

  1. Setting up password validation plugin
  2. Changing root password
  3. Removing anonmyous users
  4. Disabling remote root login
  5. Removing test database
  6. Reloading privilege tables

Modifying Root Authentication

For MySQL 8.0+, use this method to udpate root credentials:

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

Restart the MySQL service to apply changes:

sudo systemctl restart mysql

Connecting to MySQL

Access the MySQL shell with:

mysql -u root -p

Once connected, you can manage databases:

SHOW DATABASES;
CREATE DATABASE sample_db;
DROP DATABASE sample_db;

Tags: MySQL Ubuntu database Server Configuration Security

Posted on Thu, 14 May 2026 01:45:18 +0000 by DevXen