Introduction
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
Let's have look at the currently set of databases by the typing command below:
SHOW DATABASES;
Create database, for example with product from grocery online-store, by entering command:
CREATE DATABASE product;
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
In that case unnecessary to use semicolon at the end of the entering command, let's check active database:
SELECT DATABASE();
Now we can create tables with the same name of our category of product, but at the first we need to check them:
SHOW TABLES;
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.
If you will use command again:
SHOW TABLES
Then you can see created table for our database, let's check our parameters and configuration:
DESCRIBE product
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.
Conclusion
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.