• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install MySQL on Ubuntu 20.04

Written by Admin, Updated On May 1, 2020
mysql, ubuntu
How to Install MySQL on Ubuntu 20.04

MySQL is most popular open-source database management system. MySQL installation on Ubuntu is very easy and it’s commonly being a part of the popular LAMP and LEMP stacks. This tutorial explain how to install MySQL on Ubuntu 20.04 Focal Fossa systems.

Install MySQL on Ubuntu#

MySQL version 8.0 is the latest version of MySQL available in the Ubuntu repositories while writing this article. Perform the following steps as root or sudo user to install:

Step 1 – Install MySQL#

First, update the index list:

sudo apt update

Run the below command to install:

sudo apt install mysql-server

It will ask you to set MySQL root user password. MySQL service will start automatically upon the installation complete.

Step 2 – Verify MySQL Installation#

Verify the installation by checking whether the MySQL server is running. Type below command:

sudo systemctl status mysql

It should show below output if service active:

● mysql.service - MySQL Community Server
      Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
      Active: active (running) since Tue 2020-05-01 04:59:52 UTC; 2min 1s ago
    Main PID: 6260 (mysqld)
      Status: "Server is operational"

Step 3 – Secure MySQL Installation#

You can improve MySQL security by execute the mysql_secure_installation command. It’s a MySQL inbuilt security script. Run then below command:

sudo mysql_secure_installation

Once you execute this command it will prompt you to enter root user password which you set before this step. After that, it will ask you to choose whether to use the VALIDATE PASSWORD PLUGIN or not, which can be used to test the strength of your MySQL password. Press ENTER if you don’t want to set up the validate password plugin.

Next, It will ask if you want to change current root user password. If your current password is perfect then, enter N for No at the prompt.

Now, for all next questions press Y and hit Enter key for each. This will remove some anonymous users and test database, disable remote root logins and load these new rules so that MySQL immediately respects the changes you have made. Following questions will be prompted and you have to press yes/y for all :

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 4 – Connect to MySQL#

You can login to MySQL server using command line using below command:

mysql -u root -p

You will be prompted to enter root user password which you set before and it will show you output as below:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.15 MySQL Community Server - GPL

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Conclusion#

You learned how to install MySQL 8.0 and Secure MySQL on Ubuntu 20.04 Focal Fossa.

If you are facing any issue, feel free to leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install and Configure an NFS Server on CentOS 8
Next Article   How to Install VirtualBox Guest Additions on Debian 10

Related Posts

  • How to Install and Use PHP Composer on Ubuntu 22.04

    How to Install Composer on Ubuntu 22.04

    January 31, 2023
  • How to Install Nginx on Ubuntu 22.04

    How to Install Nginx on Ubuntu 22.04

    January 28, 2023
  • How to Install Puppet Agent on Ubuntu 22.04

    How to Install Puppet Agent on Ubuntu 22.04

    January 22, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Jenkins on Debian 11
    How to Install Jenkins on Debian 11 January 5, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook