mysql

From RaySoft

mysql is a simple SQL shell. It supports interactive and non-interactive use. When used interactively, query results are presented in an ASCII-table format. When used non-interactively, the result is presented in tab-separated format. The output format can be changed using command options.[1]

Documentation

Syntax

mysql [PARAMETER ...] [DATABASE]

Parameters

-B, --batch
Print results using tab as the column separator, with each row on a new line. With this option, mysql does not use the history file.
-C, --compress
Compress all information sent between the client and the server if both support compression.
-e SQL, --execute=SQL
Execute the SQL statement and quit. The default output format is like that produced with --batch.
-p[PASSWORD], --password[=PASSWORD]
The PASSWORD to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, you are prompted for one.
-u USER, --user=USER
The MySQL USER to use when connecting to the server.

Examples

Show all databases from 'localhost'
mysql --user='alex' --password --batch --execute='SHOW DATABASES'

References

  1. man 1 'mysql'