Easy ways to install MySQL on Ubuntu Linux

On this occasion I will share an installation tutorial MySQL on Ubuntu-based Linux distributions. You will also learn how to verify the installation and connect to it MySQL for the first time.

MySQL is a classic database management system. It is used in many technology stacks, including Stack LAMP (Linux, Apache, MySQL, PHP) Are popular. It has proven its stability. Another thing that does MySQL Open Source is very good.

As To install and use MySQL 8.0 on Ubuntu 18.04. Let’s begin!

I’ll cover two ways you can install MySQL on Ubuntu 18.04:

  1. To install MySQL from the Ubuntu repositories. Very simple, not the latest version (5.7)
  2. To install MySQL with the official repository. There is one bigger step to add to the process, but nothing you need to worry about. They also have the latest version (8.0)

I’ll type the command in terminal ( Standard hotkeys : CTRL + ALT + T).

Method 1.
Install MySQL from Ubuntu repositories

sudo apt update

Install now MySQL 5.7 , just type:

sudo apt install mysql-server -y

There he is! Simple and efficient.

Method 2. Install MySQL using the official repository

Although there are a few more steps in this method, I’ll go through them one by one, trying to take clear notes.

The first step is to navigate to the official website’s download page MySQL.

Open here Download link to the DEB packages.

How to install MySQL on Ubuntu Linux

Scroll down over the Oracle Web information and right click No thanks, just start my download. Select Copy link location .

Now go back to the terminal. We use the command Beckon to download the package:

curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb

https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb is the link I copied from the website. It can differ depending on the current MySQL version. Let’s use dpkg to start installing MySQL:

sudo dpkg -i mysql-apt-config *

Update your repository:

sudo apt update

To actually install MySQL I would use the same command as in the first method:

sudo apt install mysql-server -y

This will open a prompt in your terminal for Package configuration . use Down arrow select an option OK.

How to install MySQL on Ubuntu Linux

Press Enter . You will be asked to enter it password. Basically you define the root password for MySQL. Not to be confused with the Ubuntu system’s root password.

How to install MySQL on Ubuntu LinuxEnter the password and press tab Select . Press Enter. You have to now Enter return password . Then press tab again to choose from . Press Enter.

How to install MySQL on Ubuntu LinuxA number of information about the configuration of the MySQL server is presented. Press tab Select and Enter again:

How to install MySQL on Ubuntu LinuxHere you have to choose Standard authentication plugin . Assure yourself Use strong password encryption chosen. Press tab then Enter. You have successfully installed MySQL.

Check MySQL installation

to to verify that MySQL is installed correctly, use:

sudo systemctl-status mysql.service

How to install MySQL on Ubuntu LinuxYou’ll see Active: active (running) there somewhere. Otherwise, use the following command to start the service:

sudo systemctl start mysql.service

For a fresh installation, you need to run the command provided for security updates:

sudo mysql_secure_installation

First you will be asked if you want to use CHECK THE PASSWORD COMPONENT . If you want to use it, you need to choose a minimum password strength ( 0 – Low, 1 – Medium, 2 – High ). You cannot enter a password that does not comply with the selected rules.

If you’re not used to using strong passwords, this can come in handy. If you think it may help, give in Yes or Yes and press Enter , then choose Power level for your password and enter the one you want to use. If successful, the process will continue Safety, otherwise you will have to enter the password again.

However, if you don’t want this feature (I don’t) just press Enter or other button to skip it.

For other options, I recommend activate it (tap Yes or Yes and press EnterFor each). You (in this order): Remove anonymous user, disallow remote root login, delete and access test database, reload authorization table now.

Connecting to and Disconnecting from MySQL Server

To be able to execute SQL queries, you must first connect to the server via MySQL and use the MySQL command prompt. The command for this is:

mysql -h hostname -u user -p

  • -H used to determine Hostname (if the server is on a different computer; otherwise just ignore it)
  • -u mention user
  • -P Indicate that you want to enter password.

Although not recommended (for security reasons), you can enter the password right on the command by typing it right after it -P .

For example, if the password for test_user is 1234 and you are trying to connect to the computer you are using, you can use:

mysql -u test_user -p1234

When you have successfully entered the required parameters, you will be sent by. welcomed MySQL shell prompt ( mysql> ):

How to install MySQL on Ubuntu Linuxto separate from the server and leaving MySQL prompt, enter:


Type stop (MySQL is not case sensitive) or Q will work too. Press Enter Get out of something.

You can also view information execution with a simple command:

sudo mysqladmin -u root version -p

For a list of options, use:

mysql – help

If you want to uninstall MySQL

If you decide to upgrade to a newer version or just want to stop using MySQL.

First, disable the service:

sudo systemctl stop mysql.service && sudo systemctl deactivate mysql.service

Make sure to back up your database in case you want to use it later. You can uninstall MySQL by running:

sudo apt mysql clean up *

Clear cache:

sudo apt autoremove

In this article I discussed Install MySQL under Ubuntu-Linux. Hope it’s useful.

Leave a Reply

Your email address will not be published.