MySQL Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 4.10

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:

\mysql\bin\mysql [OPTIONS] [database]

mysql version 5.0 supports about 65 commands. You can get a list of supported commands by:

\mysql\bin\mysql --help

\mysql\bin\mysql  Ver 14.12 Distrib 5.0.45, for Win32 (ia32)
Copyright (C) 2002 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free 
software, and you are welcome to modify and redistribute it under the
GPL license
Usage: \mysql\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.
  -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. WARNING: options deprecated; use 
                      --disable-auto-rehash instead.
  -B, --batch         Don't use history file. Disable interactive 
                      behavior. (Enables --silent)
  --character-sets-dir=name
                      Directory where character sets are.
  --default-character-set=name
                      Set the default character set.
  -C, --compress      Use compression in server/client protocol.
  -#, --debug[=#]     This is a non-debug version. Catch this and exit
  -D, --database=name Database to use.
  --delimiter=name    Delimiter to be used.
  -e, --execute=name  Execute command and quit. (Disables --force and 
                      history file)
  -E, --vertical      Print the output of a query (rows) vertically.
  -f, --force         Continue even if we get an sql error.
...
  

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:

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

\mysql\bin\mysql --host=localhost --user=root mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)

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

mysql> quit;
Bye

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

Table of Contents

 About This Book

 Introduction of SQL

 MySQL 4.0 Introduction and Installation

 Installing MySQL 5.5.15

 Installing MySQL 5.0.2 (Alpha)

Introduction of MySQL 5.0 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

 References

 Printable Copy - PDF Version

Dr. Herong Yang, updated in 2011
mysql - The Client Tool for End Users