mysql - The Client Tool for End Users

This section provides a quick introduction of mysql, the client tool for end users to manage their data on MySQL servers. You can run mysql on a remote system to create new databases and new tables, to insert, update or delete data from tables.

What Is mysql? mysql is a client tool program for database end users to manage data on a MySQL server remotely. The syntax to run mysqladmin is:

herong> %mysql%\bin\mysql [OPTIONS] [database]

mysql version 8.0 supports a long list of options. You can get a list of supported options by:

herong> %mysql%\bin\mysql --help

  C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql
  Ver 8.0.16 for Win64 on x86_64 (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.

Usage: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql [OPTIONS]
   [database]

  -?, --help      Display this help and exit.
  -I, --help      Synonym for -?
  --auto-rehash   Enable automatic rehashing. One doesn't need to use
                  'rehash' to get table and field completion, but
                  startup and reconnecting may take a longer time.
                  Disable with --disable-auto-rehash.
                  (Defaults to on; use --skip-auto-rehash to disable.)
  -A, --no-auto-rehash
                  No automatic rehashing. One has to use 'rehash' to
                  get table and field completion. This gives a quicker
                  start of mysql and disables rehashing on reconnect.
  --auto-vertical-output
                  Automatically switch to vertical output mode if the
                  result is wider than the terminal width.
  -B, --batch     Don't use history file. Disable interactive behavior
                  (Enables --silent.)
  --bind-address=name IP address to bind to.
  --character-sets-dir=name
                  Directory for character set files.
  ...

Variables (--variable-name=value)
and boolean options {FALSE|TRUE}  Value (after reading options)
--------------------------------- ----------------------------------------
auto-rehash                       TRUE
auto-vertical-output              FALSE
bind-address                      (No default value)
character-sets-dir                (No default value)
column-type-info                  FALSE
comments                          FALSE
compress                          FALSE
database                          (No default value)
default-character-set             auto
delimiter                         ;
...

Three options are important to run mysql, --host=name, --user=name and --password=***. These options allows you to specify the host name where the MySQL server is running, the user name to be used to access the server, and the password to authenticate the user..

Here are some examples of using mysql to access the MySQL server running on my local host with "root" as the user name.

(Make sure MySQL server is running)

herong> %mysql%\bin\mysql
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using
password: NO)

herong> %mysql%\bin\mysql --host=localhost \
   --user=root --password=TopSecret

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 29
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> quit;
Bye

Table of Contents

 About This Book

 Introduction of SQL

 MySQL Introduction and Installation

Introduction of MySQL Programs

 List of MySQL Programs

 mysqld - The MySQL Server Program

 mysqladmin - The Client Tool for Administrators

mysql - The Client Tool for End Users

 Using "mysql" Command to Run SQL Statements

 mysqldump - Dumping Data to Files

 --secure-file-priv="" - MySQL Server Option

 mysqlimport - Loading Data from Files

 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