YouTube Icon

Code Playground.

How to Install MySQL on Ubuntu 18.04


How to Install MySQL on Ubuntu 18.04

MySQL is the most famous open-source social information base administration framework. It is quick, simple to utilize, versatile, and an indispensable piece of the well known LAMP and LEMP stacks. 

In this instructional exercise, we will tell you the best way to introduce and make sure about MySQL on a Ubuntu 18.04 machine. 


Ensure you are signed in as a client with sudo advantages . 

Installing MySQL on Ubuntu

At the hour of composing this article, the most recent rendition of MySQL accessible from the authority Ubuntu vaults is MySQL adaptation 5.7. 

To introduce MySQL on your Ubuntu worker follow the means underneath: 

To start with, update the well-suited bundle file by composing: 

sudo apt update

At that point introduce the MySQL bundle with the accompanying order: 

sudo well-suited introduce mysql-worker 

When the establishment is finished, the MySQL administration will begin consequently. To check whether the MySQL worker is running, type: 

sudo apt install mysql-server
sudo systemctl status mysql
? mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-06-20 11:30:23 PDT; 5min ago
 Main PID: 17382 (mysqld)
    Tasks: 27 (limit: 2321)
   CGroup: /system.slice/mysql.service
           `-17382 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/

Securing MySQL

MySQL worker bundle accompanies a content considered mysql_secure_installation that can play out a few security-related tasks. 

Show the content to composing: 

sudo mysql_secure_installation

You will be approached to arrange the VALIDATE PASSWORD PLUGIN which is utilized to test the strength of the MySQL clients' passwords and improve the security. There are three degrees of secret phrase approval strategy, low, medium and solid. Press ENTER on the off chance that you would prefer not to set up the approve secret key module. 

On the following brief, you will be approached to set a secret word for the MySQL root client. When you do that the content will likewise request that you eliminate the mysterious client, limit root client admittance to the nearby machine and eliminate the test information base. You should answer "Y" (yes) to all inquiries. 

Login as root

To collaborate with the MySQL worker from the order line you can utilize the MySQL customer utility which is introduced as a reliance of the MySQL worker bundle. 

In Ubuntu frameworks running MySQL 5.7 (and later), the root client is confirmed by the auth_socket module naturally. 

The auth_socket module confirms clients that interface from the localhost through the Unix attachment document. This implies that you can't validate as root by giving a secret key. 

To sign in to the MySQL worker as the root client type: 

sudo mysql

You will be given the MySQL shell as demonstrated as follows: 

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.22-0ubuntu18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, 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

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

On the off chance that you need to login to your MySQL worker as root from an outside program, for example, phpMyAdmin you have two alternatives. 

The first is to change the verification technique from auth_socket to mysql_native_password. You can do that by running the accompanying order: 

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'very_strong_password';

The second, prescribed alternative is to make another managerial client with admittance to all information bases: 

GRANT ALL PRIVILEGES ON *.* TO 'administrator'@'localhost' IDENTIFIED BY 'very_strong_password';


Since your MySQL worker is fully operational and you realize how to associate with the MySQL worker from the order line, you should check the accompanying aides: 

Instructions to oversee MySQL client records and information bases 

The most effective method to reset a MySQL root secret word 

The most effective method to Create a MySQL Database 

In the event that you lean toward a web interface over order line, you can introduce phpMyAdmin and deal with your MySQL information bases and clients through it.