Chapter 66. Overview of the Client-Side Scripts and Utilities

All MySQL clients that communicate with the server using the mysqlclient library use the following environment variables:

NameDescription
MYSQL_UNIX_PORTThe default socket; used for connections to localhost
MYSQL_TCP_PORTThe default TCP/IP port
MYSQL_PWDThe default password
MYSQL_DEBUGDebug-trace options when debugging
TMPDIRThe directory where temporary tables/files are created

Use of MYSQL_PWD is insecure. See Connecting.

On Unix, the mysql client uses the file named in the MYSQL_HISTFILE environment variable to save the command-line history. The default value for the history file is $HOME/.mysql_history, where $HOME is the value of the HOME environment variable. See Environment variables.

If you do not want to maintain a file that contains a record of your queries, first remove .mysql_history if it exists, then use either of the following techniques:

All MySQL programs take many different options. However, every MySQL program provides a --help option that you can use to get a full description of the program's different options. For example, try mysql --help.

You can override default options for all standard programs by specifying options on the command line or in an option file. Program Options.

The following list briefly describes the MySQL client programs and utilities:

msql2mysql A shell script that converts mSQL programs to MySQL. It doesn't handle all cases, but it gives a good start when converting.
mysql The command-line tool for interactively entering queries or executing queries from a file in batch mode. See mysql.
mysqlcc This program provides a graphical interface for interacting with the server. See mysqlcc.
mysqlaccess A script that checks the access privileges for a host, user, and database combination.
mysqladmin Utility for performing administrative operations, such as creating or dropping databases, reloading the grant tables, flushing tables to disk, and reopening log files. mysqladmin can also be used to retrieve version, process, and status information from the server. See mysqladmin.
mysqlbinlog Utility for reading queries from a binary log. Can be used to recover from a crash with an old backup. See mysqlbinlog.
mysqldump Dumps a MySQL database into a file as SQL statements or as tab-separated text files. Enhanced freeware originally by Igor Romanenko. See mysqldump.
mysqlimport Imports text files into their respective tables using LOAD DATA INFILE. See mysqlimport.
mysqlshow Displays information about databases, tables, columns, and indexes.
replace A utility program that is used by msql2mysql, but that has more general applicability as well. replace changes strings in place in files or on the standard input. Uses a finite state machine to match longer strings first. Can be used to swap strings. For example, this command swaps a and b in the given files:
   shell> replace a b b a -- file1 file2 ...