How to install MySQL properly in Linux?

MySQL is relational database which is used in most of the programming language

It is very easy to use and implement and use

So we will show you how to install MySQL properly

I’m using Ubuntu pop-os distribution

Install MySQL

We can install MySQL using two methods through CLI. First, we will share you ubuntu repository method

You need to open Linux Terminal and pass commnand

$ sudo apt update

After update now install MySQL

$ sudo apt install mysql-server -y

Installation is completed now you have to setup MySQL server.

$ sudo mysql_secure_installation
install MySQL Linux setup
Setup Password

Now you have to set new password for myql root and confirm the password.

If the password is less than 25 words then press, Yes and many other options will ask you to yes or no. Press yes or y for the rest of the options.

To get login in MySQL pass below command to terminals,it will ask password for MySQL root user.

$ sudo mysql -u root -p

Before this check wheter mysql is running otherwise you will not able to run mysql.

$ sudo systemctl status mysql.service
MySQL status check
MySQL status check

That’s it for the CLI method you are ready to use, Now we will see how we can install MySQL through the GUI way.

Method 2. Installing MySQL From Official Website

If you prefer installing MySQL through the official website way you can follow step by step Before moving ahead first download the file from the official MySQL website.

Download package through MySQL website
Download package through MySQL website

Click on Download button and new page will open,if you want to register you can else you just click on No thanks,Just download

Copy the link
Copy the link

You can download the file then install but we will use wget to download the file right-click on No thanks, just start my download and copy the link.


After downloading install MySQL deb file.

$ sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb 

Now select the distribution name then click on OK after this update the repository.

$ sudo apt update

Rest all the process will be the same as method 1

$ sudo apt install mysql-server -y

You have to set password and few question will be asked and you have to just press “y”.

Now MySQL is installed successfully in your system.

Read this if you want to know: How to change MySQL 3306 port to something else.


This was the basic way to install MySQL in your Linux-based system. In upcoming article will help you with basic usage.

Leave a Reply

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.