- Home ›
- MySQLの使い方 ›
- MySQLコマンドラインツールの使い方 ›
- HERE
コマンドの入力と実行
広告
MySQLコマンドラインツールを起動しMySQLサーバへ接続すると、任意のSQL文を実行することができます。またSQL文を実行するだけではなく、用意されたコマンドを実行することもできます。ここではコマンドの実行方法について確認します。
まずはMySQLコマンドラインツールを起動して下さい。
次のようなプロンプトが表示されます。
mysql>
この状態からSQL文を入力したりコマンドを入力します。コマンドを入力する時は次のように行います。
mysql> コマンド名
コマンド名を入力した後でEnterキーを押して実行して下さい。では例として「status」コマンドを実行してみます。
コマンドの種類によりますが、何らかの結果を画面に出力した後で入力待ちの状態となります。
コマンドの種類
ではどのようなコマンドが用意されているか確認してみます。「help」コマンドを実行して下さい。
コマンドの一覧と簡単な説明が表示されます。出力された内容をまとめたものを次にまとめました。
コマンド名 | 短縮形 | 説明 |
---|---|---|
? | ¥? | Synonym for `help'. |
clear | ¥c | Clear the current input statement. |
connect | ¥r | Reconnect to the server. Optional arguments are db and host. |
delimiter | ¥d | Set statement delimiter. |
ego | ¥G | Send command to mysql server, display result vertically. |
exit | ¥q | Exit mysql. Same as quit. |
go | ¥g | Send command to mysql server. |
help | ¥h | Display this help. |
notee | ¥t | Don't write into outfile. |
¥p | Print current command. | |
prompt | ¥R | Change your mysql prompt. |
quit | ¥q | Quit mysql. |
rehash | ¥# | Rebuild completion hash. |
source | ¥. | Execute an SQL script file. Takes a file name as an argument. |
status | ¥s | Get status information from the server. |
tee | ¥T | Set outfile [to_outfile]. Append everything into given outfile. |
use | ¥u | Use another database. Takes database name as argument. |
charset | ¥C | Switch to another charset. Might be needed for processing binlog with multi-byte charsets. |
warnings | ¥W | Show warnings after every statement. |
nowarning | ¥w | Don't show warnings after every statement. |
各コマンドは通常のものと短縮形がありどちらを使って頂いても同じです。例えばコマンドラインツールを終了するには「quit」と入力して頂いても「¥q」と入力しても同じです。
mysql> quit
mysql> ¥q
( Written by Tatsuo Ikura )