top of page

#OperationSnatchBack presents: Ashfit 2021 Transformation Challenge Group

Public·862 members

Easy Guide to Install MySQL on Ubuntu 22.04 for Beginners



Hey everyone,

If you’re setting up a web server, developing a database-driven application, or simply learning Linux-based server management, knowing how to Install MySQL on Ubuntu 22.04 is a must-have skill. MySQL is one of the most popular open-source relational database management systems used globally, and Ubuntu 22.04 LTS is one of the most stable Linux distributions available today.

In this post, I’ll share a detailed, beginner-friendly tutorial on how to install and configure MySQL on Ubuntu 22.04. This guide is based on the official documentation from Vultr

 Why Use MySQL on Ubuntu 22.04?

MySQL is powerful, secure, and widely supported across frameworks and platforms. Ubuntu 22.04, aka Jammy Jellyfish, is a long-term support release, making it a great base OS for development or production environments.

Combining these two offers:

  • Stable and secure database performance

  • Seamless integration with PHP, Python, Node.js, etc.

  • Support for popular CMS platforms like WordPress and Joomla

  • A scalable solution for websites, applications, and enterprise-level systems

What You Need Before You Start

To follow this tutorial, ensure you have:

  • A system running Ubuntu 22.04

  • A user account with sudo privileges

  • Access to a terminal (or SSH for remote installations)

  • Internet connection to download packages

Steps to Install MySQL on Ubuntu 22.04

Step 1: Update Your System

Before installing anything, update your package index:

sudo apt update


Step 2: Install MySQL Server

Install the MySQL server package using:

sudo apt install mysql-server


This will install the latest MySQL version available in Ubuntu's default repositories.

Step 3: Check MySQL Status

After installation, check if the MySQL service is running:

sudo systemctl status mysql


It should show active (running) status. If it isn’t running, you can start it using:

sudo systemctl start mysql


Secure Your MySQL Server

Run the included security script to tighten your MySQL configuration:

sudo mysql_secure_installation


You’ll be prompted to:

  • Set a root password

  • Remove anonymous users

  • Disallow root login remotely

  • Remove the test database

  • Reload privilege tables

We recommend answering “Yes” to all prompts unless you have specific needs.

Log Into MySQL

Access the MySQL command-line tool:

sudo mysql


Once inside, you can begin creating databases and users.

Create a Database and User

Here’s how to create a database and a user with full privileges:

CREATE DATABASE mydatabase;

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';

GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';

FLUSH PRIVILEGES;

EXIT;


Enable Remote Access (Optional)

If you want to connect to MySQL from another machine:

Edit the config file: sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf


Find bind-address = 127.0.0.1 and change it to: bind-address = 0.0.0.0


Save the file and restart MySQL: sudo systemctl restart mysql


Allow MySQL port through the firewall: sudo ufw allow 3306


Uninstall MySQL (Optional)

If you need to remove MySQL for any reason:

sudo apt remove --purge mysql-server mysql-client mysql-common

sudo apt autoremove

sudo apt autoclean


Conclusion

That’s it! You now know how to Install MySQL on Ubuntu 22.04 safely and securely. Whether you're building your first web app or setting up a production server, this setup provides a solid and scalable database solution.


18 Views

Members

© 2024 CHIC IN A BAG                For More Info /  Contact us at 225-247-0813 or chicinabag@gmail.com

  • Facebook Social Icon
  • Twitter Social Icon
  • CHIC In A Bag Productions
bottom of page