MySQLコマンドの一覧とコマンドの実行

MySQL コマンドラインツールを起動すると SQL 文を実行することができますが、他にも MySQL コマンドと呼ばれるコマンドがいくつか用意されています。ここでは MySQL コマンドの一覧とコマンドの実行方法について解説します。

(Last modified: )

MySQLコマンドの一覧

MySQL コマンドラインツールを起動してください。

MySQLコマンドの一覧(1)

用意されている MySQL コマンドの一覧を表示するには help; と実行してください。

help;

MySQLコマンドの一覧(2)

コマンドの一覧が表示されました。

MySQLコマンドの一覧(3)

表示された コマンドの一覧と説明は次のようなものです。

コマンド名短縮形説明
?\?Synonym for `help'.
clear\cClear the current input statement.
connect\rReconnect to the server. Optional arguments are db and host.
delimiter\dSet statement delimiter.
ego\GSend command to mysql server, display result vertically.
exit\qExit mysql. Same as quit.
go\gSend command to mysql server.
help\hDisplay this help.
notee\tDon't write into outfile.
print\pPrint current command.
prompt\RChange your mysql prompt.
quit\qQuit mysql.
rehash\#Rebuild completion hash.
source\.Execute an SQL script file. Takes a file name as an argument.
status\sGet status information from the server.
tee\TSet outfile [to_outfile]. Append everything into given outfile.
use\uUse another database. Takes database name as argument.
charset\CSwitch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings\WShow warnings after every statement.
nowarning\wDon't show warnings after every statement.
resetconnection\xClean session context.

各コマンドは通常のものと短縮形がありどちらを使って頂いても同じです。例えば MySQL コマンドラインツールを終了する時に使用する quit コマンドは quit と実行しても \q と実行しても同じ結果となります。

quit;
\q

MySQLコマンドの実行方法

MySQL コマンドラインツールの画面から MySQL コマンドを実行するには次のように行います。

mysql> コマンド名;

コマンド名の最後にはセミコロン(;)を付けてください。(ただ実際には省略しても問題ないようです)。

例として status コマンドを実行してみます。

mysql> status;

MySQLコマンドの実行方法(1)

status コマンドが実行されました。

-- --

MySQL コマンドの一覧とコマンドの実行方法について解説しました。

( Written by Tatsuo Ikura )

Profile
profile_img

著者 / TATSUO IKURA

プログラミングや開発環境構築の解説サイトを運営しています。