This tutorial will help you to install the MySQL server on Ubuntu 22.04 Jammy Jellyfish Linux systems.

Prerequisities

You must have a running Ubuntu 20.04 Linux system with sudo privileges user access.

Step 1 – Installing MySQL on Ubuntu 22.04

The default Ubuntu repositories contain MySQL 8.0. Which can be installed directly using the package manager without adding third-party PPA. To install the available MySQL server version, execute the following command. Press ‘y’ for any confirmation asked by the installer. Once the installation is finished, you can secure the MySQL server by executing the following command. You will go through a wizard of questions to secure the MySQL server. Follow the onscreen instructions below: You have secured the MySQL server in the LAMP stack on Ubuntu 22.04 Linux system.

Step 2 – Connect to MySQL Server

Remember that the above password set for the root accounts is used for remote users only. To log in from the same system, just type mysql on terminal.

Step 3 – Creating Database and Users

Here is few example queries to create database and users in MySQL server.

Create a database named ‘mydb’.CREATE DATABASE mydb; Next, create a user named ‘myuser’ accessible from ‘localhost’ only.CREATE USER ‘myuser’@’localhost’ IDENTIFIED BY ‘secure_password_’; Grant permissions on database to user.GRANT ALL ON mydb.* to ‘myuser’@’localhost’; Apply the permission changes at runtime.FLUSH PRIVILEGES;

Step 4 – Manage MySQL Service

To check the database server status.sudo systemctl status mysql Use below command to start MySQL server.sudo systemctl start mysql To stop MySQL server:sudo systemctl stop mysql Restart MySQL database server, type:sudo systemctl restart mysql

Step 5 – Uninstall (Remove) MySQL Server

If you no longer need to use the MySQL server, uninstall it from your server. To remove MySQL server type: To completely uninstall MySQL, remove the following folders as well.

Conclusion

This tutorial helped you to install the MySQL server on Ubuntu 20.04 LTS Linux system. Also includes instructions to secure the database server and uninstall it.