How to Install MySQL on Ubuntu 20.04

How to Install MySQL on Ubuntu 20.04
Techiio-author
Written by Shuvhojit DebDecember 18, 2021
7 min read
MySQL
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Techiio-author
Shuvhojit Deb

Full Stack Developer

In this blog, we can know how to install MySQL on Ubuntu 20.04.

MySQL

MySQL is an open-source relational database management system. As with other relational databases, MySQL stores data in tables made up of rows and columns. Users can define, manipulate, control, and query data using Structured Query Language, more commonly known as SQL. MySQL’s name is a combination of “My,” the name of MySQL creator Michael Widenius’s daughter, and “SQL”.

A flexible and powerful program, MySQL is the most popular open-source database system in the world. As part of the widely-used LAMP technology stack (which consists of a Linux-based operating system, the Apache web server, a MySQL database, and PHP for processing), it’s used to store and retrieve data in a wide variety of popular applications, websites, and services.

blogpost

Install MySQL on Ubuntu 20.04

Hosting MySQL databases on Ubuntu 20.04 requires installing the MySQL Server package. You can also access the database from remote clients using the MySQL Client.

Follow these simple steps to install MySQL Server on Ubuntu 20.04.

Step 1: Update/Upgrade Package Repository

Update the system package repository to ensure you are installing the latest MySQL release.

1. Open the terminal and run the following command:

sudo apt update

2. Enter your password and wait for the update to finish.

3. Next, run:

sudo apt upgrade

4. Enter Y when prompted to continue with the upgrade and hit ENTER. Wait for the upgrade to finish.

Step 2: Install MySQL

1. After successfully updating the package repository, install MySQL Server by running the following command:

sudo apt install mysql-server

2. When asked if you want to continue with the installation, answer Y and hit ENTER.

blogpost

The system downloads MySQL packages and installs them on your machine.

3. Check if MySQL was successfully installed by running:

mysql --version

blogpost

Check MySQL version on Ubuntu.

The output shows which version of MySQL is installed on the machine.

Step 3: Securing MySQL

The MySQL instance on your machine is insecure immediately after installation.

1. Secure your MySQL user account with password authentication by running the included security script:

sudo mysql_secure_installation

blogpost

2. Enter your password and answer Y when asked if you want to continue setting up the VALIDATE PASSWORD component. The component checks to see if the new password is strong enough.

3. Choose one of the three levels of password validation:

  • 0 - Low. A password containing at least 8 characters.
  • 1 - Medium. A password containing at least 8 characters, including numeric, mixed case characters, and special characters.
  • 2 - Strong. A password containing at least 8 characters, including numeric, mixed case characters, and special characters, and compares the password to a dictionary file.

Enter 0, 1, or 2 depending on the password strength you want to set. The script then instructs you to enter your password and re-enter it afterward to confirm.

Any subsequent MySQL user passwords need to match your selected password strength.

Note: Even though you are setting a password for the root user, this user does not require password authentication when logging in.

The program estimates the strength of your password and requires confirmation to continue.

4. Press Y if you are happy with the password or any other key if you want a different one.

blogpost

MySQL password validation script estimates password strength.

5. The script then prompts for the following security features:

Remove anonymous users?

Disallow root login remotely?

Remove test database and access to it?

Reload privilege tables now?

The recommended answer to all these questions is Y. However, if you want a different setting for any reason, enter any other key.

For example, if you need the remote login option for your server, enter any key other than Y for that prompt.

Step 4: Check if MySQL Service Is Running

Upon successfully installing MySQL, the MySQL service starts automatically.

Verify that the MySQL server is running by running:

sudo systemctl status mysql

The output should show that the service is operational and running:

blogpost

Step 5: Log in to MySQL Server

Finally, to log in to the MySQL interface, run the following command:

sudo mysql -u root

blogpost

MySQL
Install MySQL
0 VIEWS 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWS SHARE
Was this blog helpful?
techiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plantechiio-price-plan
You must be Logged in to comment
Code Block
Techiio-author
Shuvhojit Deb
Full Stack Developer
Techiio-followerTechiio-follower
117 Blog Posts
0 Discussion Threads
Trending Technologies
15
Software91
DevOps48
Frontend Development24
Backend Development20
Server Administration17
Linux Administration28
Data Center24
Sentry24
Terraform23
Ansible83
Docker70
Penetration Testing16
Kubernetes21
NGINX20
JenkinsX17
Techiio-logo

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Developed and maintained by Wikiance
Developed and maintained by Wikiance