How to Install MySQL on Ubuntu

Introduction

MySQL is a powerful and widely used relational database management system. If you're running an Ubuntu system and are looking to install MySQL, you're in the right place. This guide will help you set up MySQL seamlessly on Ubuntu.

Prerequisites

  • An Ubuntu system.
  • Access to the terminal and superuser (sudo) privileges.

Installation Steps

1. Update Package Database:

First, ensure that your system's package database is up-to-date with the command:

sudo apt update

2. Install the MySQL Server Package:

Once updated, you can install the MySQL package with the following command:

sudo apt install mysql-server

3. Secure Your Installation:

After the installation, run the security script to harden your MySQL installation:

sudo mysql_secure_installation

4. Start the MySQL Service:

To ensure MySQL starts upon boot and is running, use the commands:

sudo systemctl enable mysql
sudo systemctl start mysql

5. Test the Installation:

Confirm MySQL is working by logging in:

mysql -u root -p
Enter the password when prompted, and you should gain access to the MySQL shell.

Reference Links


Comments