How to install MySQL on Ubuntu

Step 1: Enable MySQL Apt Repositories

wget -c https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb

Then install the MySQL repository package by using the below command.

 sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb

MySQL server version 8.0 will be auto selected, just scroll down and Click/Enter on OK
Check attached screenshot for your reference.

Optional: if you want to change the mysql version 8.0 to 5.7

Click on First Option and Select MySQL 5.7 and Press Tab Button

Press Tab Button and Enter

Step 2: Refresh the Repositories

When you install new packages, you should update the repository by run below command in the terminal.

sudo apt-get update

Step 3: Install the mysql package

Then run the following command to install packages for the MySQL community server

sudo apt-get install mysql-server

Through the installation process, you will be asked to enter a password for the root user for your MySQL server, re-enter the password to confirm it and press [Enter].

Afterwards, you will be asked to select the default authentication plugin to use, then use the right arrow to choose Ok and press [Enter] to complete the package configuration.

Step 4: MySQL Secure Installation

Execute the following command to adjust security to the MySQL Server:

sudo mysql_secure_installation

It will prompt you some security options that you should choose in order to secure the MySQL server:

  • Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
  • Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
  • Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
  • Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

Step 5: Manage MySQL Server via Systemd

       Start the MySQL service

    Check status of MySQL service

sudo systemctl start mysql
sudo systemctl status mysql

Enable service: so that it can start automatically at system startup

sudo systemctl enable mysql

In this tutorial, you have learned step by step how to install MySQL on Ubuntu.

Please Drop Comment if you faced any issue at any point, I will try to reply asap.
50% LikesVS
50% Dislikes

One Comments

  • Thanks , I have just been looking for information approximately this topic for a
    long time and yours is the best I have came upon till now.
    But, what about the bottom line? Are you
    certain in regards to the source?

Comments are closed.