Skip to main content
Version: v1.1

MySQL

MySQL is an open-source relational database management system. To install the latest version of MySQL & to configure it, please follow the steps mentioned below:

MySQL 9.7.0 LTS Installation

Step 1: Download the Configurator

Download the configuration DEB package directly from Oracle:

wget https://dev.mysql.com/get/mysql-apt-config_0.8.39-1_all.deb

Install it using dpkg:

sudo dpkg -i mysql-apt-config_0.8.39-1_all.deb

When the purple terminal screen opens:

  1. Select MySQL Server & Cluster
  2. Press Enter
  3. Select mysql-9.7-lts
  4. Press Enter
  5. Select Ok
  6. Press Enter

Step 2: Refresh APT & Upgrade

sudo apt update

Install the updated MySQL Server package:

sudo apt install mysql-server -y

Installation may prompt you for Root Password. Choose a Strong Password & Re-enter it.

Confirm the installation:

mysql --version
info

If a Keyring error occurs, run the code below after replacing the Keyring ID:

curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x[Key Ring ID]" | sudo gpg --dearmor --yes -o /usr/share/keyrings/mysql-apt-config.gpg

Step 3: Secure MySQL Installation

Run the security initialization script:

sudo mysql_secure_installation

Installation may prompt you for the Root Password:

Type your Root Password and press Enter

After that, you may find several prompts likt this

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No:

Value: Y

There are three levels of password validation policy:

LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary
file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:

Value: 2

Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : Y

Value: Y (or you may enter N if your password is strong)

By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) :

Value: Y

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) :

Value: Y

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) :

Value: Y

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

Value: Y

You may now see a message like this:

All done!
tip

Once the security script completes, you can verify the installation. To authenticate as the root MySQL user using a password, run this command:

mysql -u root -p

Testing MySQL

Regardless of how you installed it, MySQL should have started running automatically. To test this, check its status.

systemctl status mysql.service

The output will be similar to the following:

Output
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2026-06-30 08:39:53 UTC; 1h 58min ago
Docs: man:mysqld(8)
https://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 26411 (mysqld)
Status: "Server is operational"
Tasks: 38 (limit: 2309)
Memory: 366.3M (peak: 410.7M)
CPU: 22.160s
CGroup: /system.slice/mysql.service
└─26411 /usr/sbin/mysqld

Start MySQL

If MySQL isn’t running, you can start it with:

sudo systemctl start mysql