Step-by-Step Tutorial to Install MySQL on Ubuntu 22.04 for Beginners
Hey everyone,
If you're new to Linux server management or simply setting up a development environment, learning how to Install MySQL on Ubuntu 22.04 is a great starting point. MySQL is one of the most widely-used open-source relational database management systems, and Ubuntu 22.04 LTS (Jammy Jellyfish) provides a stable and secure platform for deploying such services.
In this forum post, I’ll walk you through a clear and beginner-friendly guide on installing MySQL on Ubuntu 22.04. This process is simple and efficient, especially when following trusted documentation like this one from Vultr:Why Use MySQL on Ubuntu 22.04?
Ubuntu 22.04 LTS is known for its long-term stability, performance, and security — all of which are important when managing a production-grade system. MySQL complements Ubuntu perfectly as it supports large-scale applications, secure data handling, and fast query performance.
Some key advantages include:
Easy integration with popular programming languages like PHP, Python, and Node.js
Powerful user management and access control features
Compatibility with CMS platforms such as WordPress, Joomla, and Magento
Extensive community and enterprise support
Prerequisites
Before beginning the installation, ensure that:
Your system is running Ubuntu 22.04 (either desktop or server edition)
You have access to a terminal or SSH
You are using a user account with sudo privileges
You have a working internet connection
How to Install MySQL on Ubuntu 22.04
Step 1: Update System Packages
Before installing new software, it's a good practice to update your system package index:
sudo apt update
Step 2: Install MySQL Server
Install MySQL using the APT package manager:
sudo apt install mysql-server
This command installs MySQL and its required dependencies.
Step 3: Check if MySQL is Running
Once installation completes, check the MySQL service status:
sudo systemctl status mysql
If MySQL is running, you’ll see the status as “active (running).” If not, start it using:
sudo systemctl start mysql
Securing Your MySQL Server
MySQL comes with a built-in script to improve its security settings. Run:
sudo mysql_secure_installation
This script allows you to:
Set a root password
Remove anonymous users
Disallow remote root login
Remove the test database
Reload privilege tables
For most users, answering "yes" to all prompts is recommended.
Access the MySQL Shell
Log in to MySQL as root:
sudo mysql
From here, you can start managing databases and users.
Creating a Database and User
Let’s set up a new database and user with the appropriate permissions:
CREATE DATABASE mydb;
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
This is especially useful when configuring applications to use their own dedicated databases and users.
Enable Remote Access (Optional)
If you want to connect to MySQL remotely:
Open the MySQL config file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Change the bind-address from:
bind-address = 127.0.0.1
to:
bind-address = 0.0.0.0
Restart MySQL:
sudo systemctl restart mysql
Open port 3306 on your firewall:
sudo ufw allow 3306
Uninstalling MySQL (If Needed)
To remove MySQL completely:
sudo apt remove --purge mysql-server mysql-client mysql-common
sudo apt autoremove
sudo apt autoclean
Final Thoughts
That’s it! You now know how to Install MySQL on Ubuntu 22.04 and configure it for basic usage. Whether you're setting up a web server, learning Linux administration, or building a database-powered application, this process gives you a solid starting point.

