Install sql/mysql database

001 – MySQL and SQL – Getting started

First of all, to avoid any confusion, SQL it is the standard language for relational database management systems and MySQL is an open-source relational database management system. So, MySQL is a database and SQL is a language.

In order to use SQL language you have to install a relational database. One of the most popular relational databases is MySQL. Let’s install it!

I am on Linux and I installed MySQL via terminal by running the command:

sudo apt install mysql-client-core-5.7

Full detail installation guide (for all operating systems) can be found on MySQL official website.

Once MySQL is installed we can start the server by running the command:

service mysql start

Check the status of your MySQL by running the command:

service mysql status

You should get something like shown below:

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor pr
   Active: active (running) since Fri 2018-02-16 04:20:14 GMT; 12min ago
  Process: 908 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/ru
  Process: 806 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (co
 Main PID: 922 (mysqld)
    Tasks: 28 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─922 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld

Feb 16 04:20:13 ddnro systemd[1]: Starting MySQL Community Server...
Feb 16 04:20:14 ddnro systemd[1]: Started MySQL Community Server.

You exit from the status with Ctrl+C.

To enter the sql prompt run the following command:

mysql -u root -p

You will be prompt to enter the password. Enter it then press Enter.

You should be welcomed by something like this:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 5.7.21 MySQL Community Server (GPL)

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.


To quit use Ctrl+D.

Now, we need a database to can practice our SQL skills on. For this we are going to use Chinook database, well known database for learning purposes.

Make sure the terminal is open where all the files used here are located.

To download the Chinook file, run the following command in the terminal:


To create the Chinook database, run the following command:

mysql -u root -p < Chinook_MySql_AutoIncrementPKs.sql

Enter again the sql prompt by running the command:

mysql -u root -p

Enter the password then press Enter.

To see all the databases run the command:

mysql> show databases;

You should see something like shown below:

| Database           |
| information_schema |
| Chinook            |
| mysql              |
| performance_schema |
| sys                |
5 rows in set (0.00 sec)

To select Chinook run the command:

mysql> use Chinook;

You should see something like shown below:

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

To show all the tables in the Chinook use the following command:

mysql> show tables;

You should see something like shown below:

| Tables_in_Chinook |
| Album             |
| Artist            |
| Customer          |
| Employee          |
| Genre             |
| Invoice           |
| InvoiceLine       |
| MediaType         |
| Playlist          |
| PlaylistTrack     |
| Track             |
11 rows in set (0.00 sec)

Congratulations, you installed MySQL, started it, added a database to it, and used basic SQL commands.

Leave a Reply