top of page

Grupo de apoyo

Público·260 miembros

How to Install MySQL on Ubuntu 22.04: A Step-by-Step Guide for Beginners

When building a data-driven application or website, choosing a reliable and powerful database system is critical. MySQL stands out as one of the most widely used open-source relational database management systems in the world. If you're working on a Linux environment, particularly with Ubuntu 22.04, installing MySQL is a necessary step for powering dynamic websites and applications.

In this post, we’ll show you how to Install MySQL on Ubuntu 22.04 in a few easy steps. This guide is perfect for beginners and developers looking for a reliable resource, with insights taken from the official Vultr documentation.

Why Choose MySQL and Ubuntu 22.04?

Ubuntu 22.04, also known as “Jammy Jellyfish,” is a Long-Term Support (LTS) release, offering security updates and support for five years. It's a stable and secure platform for running production-grade applications.

Pairing it with MySQL gives you:

  • Reliable and fast data processing

  • Secure user authentication

  • Cross-platform support

  • Strong community support

  • Compatibility with many programming languages and CMS platforms like WordPress, Joomla, and Drupal

Prerequisites

Before you begin the installation, make sure you have the following:

  • A system running Ubuntu 22.04

  • Access to a user account with sudo privileges

  • An internet connection

  • Terminal or SSH access


Step-by-Step: How to Install MySQL on Ubuntu 22.04

1. Update System Repositories

Start by updating your local package index to ensure all packages are up to date:

sudo apt update


2. Install MySQL Server

To install MySQL on your Ubuntu 22.04 system, use the command:

sudo apt install mysql-server


This command installs the MySQL server and related packages automatically.

3. Check MySQL Service Status

Once the installation is complete, verify that the MySQL service is running:

sudo systemctl status mysql


You should see the service marked as active (running).

To start or stop the service manually:

sudo systemctl start mysql

sudo systemctl stop mysql



Securing MySQL Installation

MySQL comes with a built-in script to help you enhance its security:

sudo mysql_secure_installation


This script will guide you through:

  • Setting the root password

  • Removing anonymous users

  • Disabling remote root login

  • Removing the test database

  • Reloading privilege tables

It’s highly recommended to answer “yes” to all security prompts unless you have specific requirements.


Logging into MySQL

After the setup, log in to MySQL using:

sudo mysql


You’ll now be in the MySQL shell, where you can run SQL commands.



Creating a Database and User

Here are some basic commands to get started:

Create a database: CREATE DATABASE example_db;

  • Create a user:

  •  CREATE USER 'example_user'@'localhost' IDENTIFIED BY 'strong_password';


Grant privileges: GRANT ALL PRIVILEGES ON example_db.* TO 'example_user'@'localhost';

FLUSH PRIVILEGES;

  • Exit the shell:

  •  EXIT;


Optional: Enable Remote Access

If you want to access MySQL from another machine, you need to allow remote connections. Open the MySQL config file:

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf


Find the line:

bind-address = 127.0.0.1


And change it to:

bind-address = 0.0.0.0


Restart MySQL:

sudo systemctl restart mysql


Then update your firewall settings to allow traffic on port 3306.

Uninstall MySQL (If Needed)

To completely remove MySQL from your system:

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

sudo apt autoremove

sudo apt autoclean


Conclusion

Installing MySQL on Ubuntu 22.04 is a simple and straightforward process. Whether you're a web developer, database administrator, or tech enthusiast, this powerful combination provides a stable foundation for any project.

For a detailed reference and further options, you can follow the official Vultr tutorial. Share your experience or troubleshooting tips in the forum to help others on their MySQL journey!


1 vista

Cpyright © 2021 ConTuSalud Medical Group. Todos los derechos reservados.

bottom of page