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:

C:\herong>set "MySQL=\Program Files\MySQL\MySQL Server 5.7"
C:\herong>"%MySQL%\bin\mysql" [OPTIONS] [database]

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

C:\herong>"%MySQL%\bin\mysql" --help

\Program Files\MySQL\MySQL Server 5.7\bin\mysql  
Ver 14.14 Distrib 5.7.10, for Win32 (AMD64)

Usage: \Program Files\MySQL\MySQL Server 5.7\bin\mysql [OPTIONS] 
  -?, --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.
                  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.
                  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=xxxx. 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)

ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using 
password: NO)

C:\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 11
Server version: 5.7.10-log MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input 

mysql> quit;

The MySQL server denied the access when no user name was specified. Also note that when "root" was specified without any password, the server accepted the access.

Last update: 2015.

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 to Run SQL Statements

 mysqldump - Dumping Data to Files

 mysqlimport - Loading Data from Files

 Perl Programs and MySQL Servers

 PHP 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

 Transaction Management and Isolation Levels

 Locks Used in MySQL

 Defining and Calling Stored Procedures

 Variables, Loops and Cursors Used in Stored Procedures

 Outdated Tutorials


 PDF Printing Version