Home >> FAQs/Tutorials >> MySQL Tutorials >> Index

MySQL FAQs - Command-Line End User Interface mysql

By: FYIcenter.com

Part:   1   2  3  4 

A collection of 10 FAQs on MySQL command-line interface mysql. Clear answers are provided with tutorial exercises on mysql command option; running SQL and mysql commands; running mysql command files in batch mode; returning query output in HTML and XML formats. Topics included in this collection are:

  1. What Is the Command Line End User Interface - mysql?
  2. What Are the "mysql" Command Line Options?
  3. What Are the "mysql" Command Line Arguments?
  4. How Many SQL DDL Commands Are Supported by "mysql"?
  5. How Many SQL DML Commands Are Supported by "mysql"?
  6. What Are the Non-Standard SQL Commands Supported by "mysql"?
  7. How To Get Help Information from the Server?
  8. How To Run "mysql" Commands from a Batch File?
  9. How To Return Query Output in HTML Format?
  10. How To Return Query Output in XML Format?

Please note that all answers and tutorials are based on MySQL 5.0.

What Is the Command Line End User Interface - mysql?

"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 formated as HTML tables.
  • "mysql" allows query output to be formated as XML elements.

What Are the "mysql" Command Line Options?

"mysql" offers a big list of command line options. Here are some commonly used options:

  • "-?" - Displays a help message on how to use "mysql" and terminates the program.
  • "-u userName" - Specifies a user name for the server to authenticate when connecting to the server.
  • "-p[password]" - Specifies a password for the server to authenticate when connecting to the server.
  • "-h hostName" - Specifies a host name where the MySQL server is running. The default host name "localhost".
  • "-P portNumber" - Specifies a port number where the MySQL server is listening for connections. The default port number is 3306.
  • "-e command" - Executes the specified command and terminates the program.
  • "-t" - Specifies that the query output is displayed in text table format. This is the default display format for interactive mode.
  • "-H" - Specifies that the query output is displayed in HTML table format.
  • "-X" - Specifies that the query output is displayed in XML element format.

Here is a tutorial exercise of how to use the "-?" option with "mysql":

>cd \mysql\bin
>mysql -?
mysql  Ver 14.12 Distrib 5.0.24, for Win32 (ia32)
Copyright (C) 2002 MySQL AB
...
Usage: 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
...

(Continued on next part...)

Part:   1   2  3  4 


Selected Developer Jobs:

More...