Steps to Install MySQL on Ubuntu 22.04 LTS Jammy Linux


This tutorial will show the simple steps to install MySQL database server on Ubuntu 22.04 LTS Jammy JellyFish using command terminal.

Oracle MySQL is the most popular open source database server in LAMP or LEMP environments. This relational database management system is used for many content management systems used to store data, for example WordPress.

The abbreviation “SQL” stands for Structured Query Language and the abbreviation “My” stands for the first name of the daughter of a MySQL developer. There is no separate graphical user interface in MySQL, but this can be implemented using external programs. There are many free programs for this that provide a graphical interface for administration and operation, such as Workbench.

How to Install MySQL on Ubuntu 22.04 LTS

The steps given here to install MySQL Server and MySQL Client package on Ubuntu 22.04 lts will be the same for previous versions of this Linux.

1. Update Apt Package Index

As we are about to use the system default repository to install the MySQL package, therefore, before going any further, let’s run the update command.

sudo apt update && sudo apt upgrade

2. Install MySQL server and client on Ubuntu 22.04

We don’t need to add a repository manually on our Ubuntu 22.04 because the packages to install MySQL Server are already available for download and setup using the standard system repository.

sudo apt install mysql-server

To note: The above command will install the server and client on your Ubuntu machine. However, if you are looking for a command to install only the MySQL client to connect the remote database server using the command line, here is how to get it:

sudo apt install mysql-client

3. To check the version

After the installation is complete to check which version of MySQL server is on your system, run the given command:

mysql --version

4. Run the security script to secure MySQL

By default, after installation, our MySQL is not secure, to increase its security we can delete the demo database, limit remote access and set a root password. Here is the command to run:

sudo mysql_secure_installation

When you run the above command, a textual wizard allows you to secure your database server. Here are the questions he will ask you:


There are three levels of password validation policy:

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

Depending on the password strength you want, select the value and hit it Walk in key.

0 = LOW



After that, enter the password you want to set for the MySQL root user.

If you get an error:

SET PASSWORD has no meaning for user ‘root’@’localhost’ because the authentication method used does not store authentication data on the MySQL server. Please consider using ALTER USER instead if you want to change authentication settings.

Then first exit the script by pressing Ctrl+C.

First connect to MySQL:

sudo mysql

Set root password:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by '[email protected]';

To note: Switch [email protected] with a strong password you want to set.



Run the secure install script again.

sudo mysql_secure_installation
Enter the password for user root: type your set password and then press ENTER.
Change the password for root? Press N, then ENTER.
Remove anonymous users? Press Y, then ENTER.
Disallow root login remotely? Press Y, then ENTER.
Remove test database and access to it? Press Y, then ENTER.
Reload privilege tables now? Press Y, then ENTER.

5. Log in to the database server as root user

After installing and securing it, we can connect to our MySQL server with a root user to create database tables or users.

sudo mysql -u root

Enter the password you assigned to it.

6. Manage MySQL Service

First let’s see the command that we can use to check if the MySQL service is running perfectly in the background without any errors. For this use:

sudo systemctl status mysql

Check MySQL Service Status

To stop the service:

sudo systemctl stop mysql


sudo systemctl restart mysql

To enable with OS boot:

sudo systemctl stop mysql

To deactivate :

sudo systemctl disable mysql

7. How to update?

If the latest version of MySQL is available for Ubuntu 22.04, we can have it by simply running the update and upgrade system command, i.e.

sudo apt update && sudo apt upgrade

8. Uninstall or remove MySQL from Ubuntu 22.04

For some reason, if you don’t need the MySQL server on your system, we can completely remove it from our Ubuntu 22.04. However, before that, make sure you have a backup of your databases if anything important is there.

sudo apt autoremove --purge mysql-server

Uninstall or remove MySQL Ubuntu 22.04

Other Items:

4 Ways to Check MySQL or MariaDB Version on Linux
How to Install phpMyAdmin on Ubuntu 22.04
Install Backdrop CMS on Ubuntu 22.04
Install PostgreSQL Server & Client on Ubuntu 22.04
How to Install VirtualBox on Ubuntu 22.04 LTS


Comments are closed.