Main page  |  Install  |  Command-line tools  |  Data Types  |  SQL  |  Operators  |  Functions  |  Table Types

MySQL quick reference

MySQL programs (command-line tools)

Client programs, Administrative and Utility programs, etc.

See:

http://dev.mysql.com/doc/refman/5.7/en/programs.html
http://dev.mysql.com/doc/refman/5.7/en/programs-client.html
http://dev.mysql.com/doc/refman/5.7/en/programs-admin-utils.html

Note:

To get help on usage and options of the programs use --help, for example: mysqldump --help

MySQL provides various command-line tools. For example:

mysql

The MySQL interactive SQL interpreter. It enables you to execute SQL on the command line. You can span your SQL across any number of lines. The tool executes your SQL when you terminate it with a semi-colon or the escape sequence \g.

Usage: mysql [OPTIONS] [database]

Typical usage:
mysql -u user -p[passwd] [-h hostname] [-e "query"] dbname

myisamchk

This tool verifies the integrity of your databases and potentially fixes any problems with them. It also performs table optimizations. It can be used only on MyISAM tables.

mysqlcheck

This client program performs table maintenance: it checks, repairs, optimizes, or analyzes tables. It is DB engine independent. mysqlcheck is similar in function to myisamchk, but works differently. The main operational difference is that mysqlcheck must be used when the mysqld server is running, whereas myisamchk should be used when it is not. The benefit of using mysqlcheck is that you do not have to stop the server to perform table maintenance.

mysqladmin

The MySQL administrative interface. Though many of this tool's functions can be accomplished using SQL and the mysql command-line utility, it nevertheless provides a quick way to perform an administrative task straight from the Unix command line without entering an SQL interpreter. You can specifically execute the following administrative commands:

create databasename

Creates the specified database.

drop databasename

The opposite of create, this command destroys the specified database.

extended-status

Provides an extended status message from the server.

flush-hosts

Flushes all cached hosts.

flush-logs

Flushes all logs.

flush-status

Flushes all status variables.

flush-tables

Flushes all tables.

flush-threads

Flushes the thread cache.

flush-privileges

Forces MySQL to reload all grant tables.

kill id[,id]

Kills the specified MySQL threads.

password new_password

Sets the password for the user to the specified new password. mysqladmin -u root password new_password should be the first thing you do with any new MySQL install.

ping

Verifies that mysqld is actually running.

processlist

Shows the active MySQL threads. You can kill these threads with the mysqladmin kill command.

reload

Reloads the grant tables.

refresh

Flushes all tables, closes all log files, then opens them again.

shutdown

Shuts MySQL down.

status

Shows an abbreviated server status.

variables

Prints out available variables.

version

Displays the server version information.

innochecksum

This tool reads an InnoDB tablespace file, calculates the pages checksum and reports any mismatch, which indicate damaged pages.

mysqlaccess

A command-line interface for managing users. This tool is basically a shortcut for the SQL GRANT command.

mysqld

The MySQL server process. You should never start this directly, instead use mysqld_safe.

mysqld_safe

The server process manager. Under MySQL versions prior to MySQL 4.0, this script is called safe_mysqld. It is a process that starts up the mysqld server process and restarts it should it crash. Note that the mysql.server startup script executes mysqld_safe as the appropriate user at server startup.

mysqldump

Dumps the state of a MySQL database or set of databases, eventually selecting tables, to a text file. You can later use this text file to restore the databases you dumped.

mysqlimport

Imports text files in a variety of formats into your database. It expects the base name (the name of the file without its extension) to match the name of the table to be used in the import.

mysqlshow

Displays the structure of the specified MySQL database objects. You can look at the structure of databases, tables, and columns.