MySQL Command Line Client Tool

A tutorial example on how to use the MySQL Command Line Client Tool to connect to MySQL Server. The example also includes SQL commands to create a new test database/table and insert some data to the table.

What Is MySQL Command Line Client Tool? MySQL Command Line Client Tool allows to connect to MySQL server and run SQL commands interactive from a command line window.

MySQL Command Line Client Tool is included in the "Full" installation using MySQL Installer.

You can start MySQL Command Line Client Tool from the "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" command.

Make sure MySQL server is running and try the following commands to play with MySQL Command Line Client Tool:

herong> "\Program Files\MySQL\MySQL Server 8.0\bin\mysql" \
   --user=root --password=TopSecret

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

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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
| world              |
+--------------------+
6 rows in set (0.07 sec)

mysql> create database test;
Query OK, 1 row affected (0.01 sec)

mysql> use test;
Database changed

mysql> create table hello (message varchar(80));
Query OK, 0 rows affected (1.24 sec)

mysql> insert into hello (message) value ('Hello world!');
Query OK, 1 row affected (0.31 sec)

mysql> select * from hello;
+--------------+
| message      |
+--------------+
| Hello world! |
+--------------+
1 row in set (0.00 sec)

mysql> drop table hello;
Query OK, 0 rows affected (0.97 sec)

mysql> quit;
Bye

Table of Contents

 About This Book

 Introduction of SQL

MySQL Introduction and Installation

 What Is MySQL

 Downloading and Installing MySQL

 Issues during MySQL Installation

 Starting and Stopping MySQL Server

 Un-Installing MySQL

MySQL Command Line Client Tool

 What Is MySQL Shell

 What Is MySQL Workbench

 Using MySQL Non-Install Package

 MySQL Data Directory Initialization

 Creating MySQL Windows Service

 %mysql% Variable for MySQL Server Path

 Introduction of MySQL Programs

 PHP Programs and MySQL Server

 Perl Programs and MySQL Servers

 Java Programs and MySQL Servers

 Datatypes and Data Literals

 Operations and Expressions

 Character Strings and Bit Strings

 Commonly Used Functions

 Table Column Types for Different Types of Values

 Using DDL to Create Tables and Indexes

 Using DML to Insert, Update and Delete Records

 Using SELECT to Query Database

 Window Functions for Statistical Analysis

 Use Index for Better Performance

 Transaction Management and Isolation Levels

 Locks Used in MySQL

 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures

 System, User-Defined and Stored Procedure Variables

 MySQL Server Administration

 Storage Engines in MySQL Server

 InnoDB Storage Engine - Primary and Secondary Indexes

 Performance Tuning and Optimization

 Bulk Changes on Large Tables

 MySQL Server on macOS

 Installing MySQL Server on Linux

 Connection, Performance and Second Instance on Linux

 Archived Tutorials

 References

 Full Version in PDF/EPUB