Thursday 12 April 2018

Install MySQL on Ubuntu

1. Update your OS (Ubuntu 16.04.3 LTS).

sudo apt-get update




2. Execute below command to install MySQL Server

sudo apt-get install mysql-server


3. Check the status

systemctl status mysql.service

o/p:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
   Active: active (running) since Tue 2017-09-05 16:35:57 IST; 1min 11s ago
 Main PID: 13536 (mysqld)
   CGroup: /system.slice/mysql.service
           └─13536 /usr/sbin/mysqld
lines 1-6/6 (END)



4. Check the version

mysqladmin -p -u root version

o/p:

Enter password: 
mysqladmin  Ver 8.42 Distrib 5.7.19, for Linux on x86_64
Copyright (c) 2000, 2017, 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.

Server version        5.7.19-0ubuntu0.16.04.1
Protocol version    10
Connection        Localhost via UNIX socket
UNIX socket        /var/run/mysqld/mysqld.sock
Uptime:            3 min 28 sec

Threads: 1  Questions: 3  Slow queries: 0  Opens: 107  Flush tables: 1  Open tables: 26  Queries per second avg: 0.014


 

5. Login to MySQL shell (with user "root")

mysql -u root -p 

o/p:

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.19-0ubuntu0.16.04.1 (Ubuntu)

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