JDBC Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 2.11

mysql - Command Line Tool

This section provides information about 'mysql' command line tool.

"mysql", official name is "MySQL monitor", is a command-line interface for end users to manage user data objects. "mysql" has the following main features:

  • "mysql" is command line interface. It is not a Graphical User Interface (GUI).
  • "mysql" supports all standard SQL Data Definition Language (DDL) commands for the server to execute.
  • "mysql" supports all standard SQL Data Manipulation Language (DML) commands for the server to execute.
  • "mysql" supports many of non-SQL commands that "mysql" will execute by itself.
  • "mysql" provides access to the server-side help system.
  • "mysql" allows command files to be executed in a batch mode.
  • "mysql" allows query output to be formatted as HTML tables.
  • "mysql" allows query output to be formatted as XML elements.

Here is how I run "mysql" and get the "help" information:

C:\>\local\mysql\bin\mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45-community-nt MySQL Community Edition (GPL)

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

mysql> help;
...

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db 
               and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the 
               line as new delimiter.
ego       (\G) Send command to mysql server, display result 
               vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
notee     (\t) Don't write into outfile.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an 
               argument.
status    (\s) Get status information from the server.
tee       (\T) Set outfile [to_outfile]. Append everything into given
               outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for 
               processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.

For server side help, type 'help contents'

Sections in This Chapter

MySQL 5.0 Download, Installation and Start

mysqladmin - MySQL Admin Tool

mysql - Command Line Tool

Creating Database and User with MySQL Monitor

Dr. Herong Yang, updated in 2007
mysql - Command Line Tool