Chapter 8. MySQL Client and Utility Programs

Table of Contents

8.1. Overview of the Client-Side Scripts and Utilities
8.2. myisampack, the MySQL Compressed Read-only Table Generator
8.3. mysql, the Command-Line Tool
8.3.8.3.1. mysql Commands
8.3.8.3.2. Executing SQL Statements from a Text File
8.3.8.3.3. mysql Tips
8.4. mysqladmin, Administering a MySQL Server
8.5. The mysqlbinlog Binary Log Utility
8.6. mysqlcc, the MySQL Control Center
8.7. The mysqlcheck Table Maintenance and Repair Program
8.8. The mysqldump Database Backup Program
8.9. The mysqlhotcopy Database Backup Program
8.10. The mysqlimport Data Import Program
8.11. mysqlshow, Showing Databases, Tables, and Columns
8.12. perror, Explaining Error Codes
8.13. The replace String-Replacement Utility

There are many different MySQL client programs that connect to the server to access databases or perform administrative tasks. Other utilities are available as well. These do not communicate with the server but perform MySQL-related operations.

This chapter provides a brief overview of these programs and then a more detailed description of each one. The descriptions indicate how to invoke the programs and the options they understand. See Chapter 4, Using MySQL Programs for general information on invoking programs and specifying program options.

Overview of the Client-Side Scripts and Utilities

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

myisampack

A utility that compresses MyISAM tables to produce smaller read-only tables. See myisampack.

mysql

The command-line tool for interactively entering SQL statements or executing them from a file in batch mode. See mysql.

mysqlaccess

A script that checks the access privileges for a host, user, and database combination.

mysqladmin

A client that performs 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

A utility for reading statements from a binary log. The log of executed statements contained in the binary log files can be used to help recover from a crash. See mysqlbinlog.

mysqlcc

A client that provides a graphical interface for interacting with the server. See mysqlcc.

mysqlcheck

A table-maintenance client that checks, repairs, analyzes, and optimizes tables. See Using mysqlcheck.

mysqldump

A client that dumps a MySQL database into a file as SQL statements or as tab-separated text files. Enhanced freeware originally by Igor Romanenko. See mysqldump.

mysqlhotcopy

A utility that quickly makes backups of MyISAM or ISAM tables while the server is running. See mysqlhotcopy.

mysqlimport

A client that imports text files into their respective tables using LOAD DATA INFILE. See mysqlimport.

mysqlshow

A client that displays information about databases, tables, columns, and indexes. See mysqlshow.

perror

A utility that displays the meaning of system or MySQL error codes. See perror.

replace

A utility program that changes strings in place in files or on the standard input. See replace utility.

Each MySQL program takes 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.

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

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

Use of MYSQL_PWD is insecure. See the section called “Keeping Your Password Secure”.

You can override the default option values or values specified in environment variables for all standard programs by specifying options in an option file or on the command line. the section called “Specifying Program Options”.