The mysql is a simple SQL shell that has input line editing capabilities. It supports interactive and noninteractive usage. When it is used interactively, query results are presented in an ASCII-table format. When it is used noninteractively, like a filter, the result would be presented in tab-separated format.
The output format can be changed with the help of command options. If there are issues because of insufficient memory for large result sets, the --quick option can be used.
This forces the mysql to retrieve results from the server, a row at a time instead of retrieving the entire result set at once and buffering it in memory before it is being displayed. This is done by returning the result set with the help of the mysql_use_result() C API function which is present in the client/server library instead of mysql_store_result().
Using mysql is an easy task. It can be invoked from the prompt of the user’s command interpreter. It has been demonstrated below −
shell> mysql db_name
shell> mysql --user=user_name --password db_name
Enter password: your_password
Then an SQL statement can be typed, and can be ended with ;, \g, or \G.
Typing Control+C interrupts the current statement if there is such a statement, or cancels any partial input line if not.
SQL statements can be executed in a script file (or batch file). It has been shown below −
shell> mysql db_name < script.sql > output.tab
On Unix, the mysql client logs statements which are executed interactively to a history file.