Home >> FAQs/Tutorials >> MySQL Tutorials

MySQL Tutorial - "mysql" Command Line Options

By: FYIcenter.com

(Continued from previous topic...)

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 topic...)

  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?

MySQL Tutorials:

More...


Other Tutorials/FAQs:

More...


Related Resources:

More...


Selected Jobs:

More...