Command-Line Tools

You can interact with MySQL entirely from the command line. In general, each MySQL command accepts as an argument any appropriate option from the configuration options listed earlier. You prefix any such option with two dashes:

mysql --user=username

In addition, each of these options has a short form:

mysql -uusername

To see which options apply to individual commands and their short forms, refer to the manpage for the command in question using the following command:

$ man -M/usr/local/mysql/man mysql

MySQL provides the following command-line tools:

msql2mysql

This utility is handy for people converting applications written for mSQL to MySQL. These days, however, few people need this help.

myisamchk

This tool verifies the integrity of your MyISAM tables and potentially fixes any problems that it detects.

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 semicolon or the escape sequence \g.

mysql_upgrade

After you install a new version of MySQL, you can run this utility to examine your tables and make sure they are consistent with your new version of MySQL. You should run this command each time you upgrade MySQL.

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 ...

Get MySQL Pocket Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.