Serverspace accelerated the answering of support requests by 40%
September 15, 2023
Updated September 13, 2023

How to create tables in MySQL?

Databases Linux


The modern DBMS system can be controlled by GUI and CLI of MySql Client, but what is the difference?

Command Line Interface (CLI) control of MySQL offers several advantages and is essential for various reasons:

  • Efficiency: CLI allows for quick and precise execution of MySQL commands, making it a preferred choice for experienced users. You can perform tasks rapidly without the need for graphical interfaces, which can sometimes be slower.
  • Scripting and Automation: CLI is ideal for scripting and automation. You can create scripts to execute a series of MySQL commands, enabling the automation of routine database tasks, backups, and maintenance.
  • Resource Efficiency: CLI consumes fewer system resources compared to graphical interfaces, making it suitable for use on servers and in scenarios where resource efficiency is crucial.
  • Remote Access: CLI provides a convenient way to connect to remote MySQL servers via SSH or other secure protocols, allowing database administrators to manage databases on remote servers securely.
  • Flexibility: With CLI, you have complete control over MySQL and can perform tasks that might not be available or easily achievable through graphical tools.

In summary, CLI control of MySQL is indispensable for its efficiency, scripting capabilities, resource efficiency, and flexibility. It is a valuable tool for both beginners and experienced database administrators, offering precise control over database operations and facilitating automation and customization of tasks. Therefore learning of administrate and control DBMS we will see on CLI, let's check!

Creation user

Taking a closer look at MySQL, assuming it's installed as database software with administrative privileges, our first step involves gaining access to the MySQL system, and we can do this by executing the following command:

mysql -u root -p -h localhost
Screenshot №1 — Login

Let's have look at the currently set of databases by the typing command below:

List of databases
Screenshot №2 — List of databases

Create database, for example with product from grocery online-store, by entering command:

Create DB
Screenshot №3 — Create DB

In the MySQL there is state of using database by default, all enter command will apply to the active DB, therefore we need to set such base:

USE product
USE command
Screenshot №4 — USE command

In that case unnecessary to use semicolon at the end of  the entering command, let's check active database:

Active DB
Screenshot №5 — Active DB

Now we can create tables with the same name of our category of product, but at the first we need to check them:


Then type next command:

CREATE TABLE product (name VARCHAR(20), tag VARCHAR(20), id INT NOT NULL, expiration DATE, production DATE);

Let's explain syntax of creation tables for MySQL:

  • CREATE TABLES — it's command syntax for creation tables, that quiet understandable definition;
  • Product — it's label of table, that we create;
  • Name — it's keyword.
Creation of table
Screenshot №6 — Creation of table

If you will use command again:


Then you can see created table for our database, let's check our parameters and configuration:

DESCRIBE product
Table of data
Screenshot №7 — Table of data

By the default settings all types of data have value NULL, that mean nothing in cell. But we can change it by parameters, that we described above.


In this instructional journey, we delved into CLI control of MySQL by exploring various commands and actions, from accessing the MySQL system to creating databases and tables. By mastering the command-line interface, users gain a deeper understanding of how to administer and control DBMS effectively.

5 out of 5
Аverage rating : 5
Rated by: 1
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.