• 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 18.04

Written by Admin, Updated On May 7, 2019
mysql, ubuntu
How To Install MySQL on Ubuntu 18.04

MySQL is an open-source and most popular 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 will help you to install MySQL on Ubuntu 18.04 Bionic Beaver systems.

Prerequisites#

Ubuntu 18.04 server with a non-root user with sudo privileges. To remote a system use SSH in Linux and in Windows you can use Putty application to make SSH connection.

Install MySQL on Ubuntu 18.04#

Before start installation you need to update the package index on your system. Execute following command :

sudo apt update

Run the below commands to start installation:

sudo apt install mysql-server

It will ask you to set MySQL root user password. On completion of installation, the MySQL service will start automatically. Also, you can check whether the MySQL server is running, type below command:

sudo systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-03-21 18:22:17 IST; 2min 1s ago
Main PID: 6260 (mysqld)
CGroup: /system.slice/mysql.service
└─6260 /usr/sbin/mysqld

Securing MySQL & Configuring#

It’s recommended to run included security script. By this script it will make changes in default options like remote root logins and sample users and test database. Run the following security script:

sudo mysql_secure_installation

Once you execute this command it will prompt you to enter root user password which you set before this step. First of all 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.

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?
Press y|Y for Yes, any other key for No:

Press Y and hit Enter to go ahead.

There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1

After that, it will ask you for select a level of password validation. Make sure here if you have select 2 for for the strongest level then it will not allow password without numbers, upper and lowercase letters, and special characters. So here you should select 1 for medium level and hit Enter.

Next, It will ask if you want to change that password. If your current password is perfect then, enter N for “no” at the prompt:

Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

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

You can login to mysql using following command as root user :

sudo mysql -uroot -p

Enter you mysql root user password and it seems you logged in.

All done. Finally, you successfully installed MySQL on your system.

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 Download Ubuntu 18.04 LTS ISO File – Desktop & Server
Next Article   How to Configure Static IP Addresses on Ubuntu 18.04 Server

Related Posts

  • How to Install WordPress with Nginx on Debian 11

    How to Install WordPress with Nginx on Debian 11

    March 22, 2023
  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install PHP 8.2 on Debian 11
    How to Install PHP 8.2 on Debian 11 Linux February 24, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 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