このエントリーをはてなブックマークに追加


MySQL接続時にWelcomeメッセージを表示しない方法

mysqlコマンドを利用しMySQLサーバに接続したとき、Welcomeメッセージが表示されます。
このメッセージを表示抑止する方法を以下に記します。

Welcomeメッセージの抑止

通常の接続の場合、Welcomeメッセージが表示されます。

# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

mysqlコマンドに-sオプションを追加することにより、Welcomeメッセージが表示されなくなり、mysqlプロンプトがすぐに表示されます。

$ mysql --help
<snip>
-s, --silent        Be more silent. Print results with a tab as separator,
                   each row on new line.
<snip>

以下、-sオプションを追加した場合の実行結果です。

Welcomeメッセージが表示されず、mysqlプロンプトがすぐに表示されているのが確認できます。

# mysql -u root -p -s
Enter password: 
mysql> 

尚、-sオプションにより以下のようなメッセージも表示されなくなります。

Query OK, 0 rows affected (0.00 sec)

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2015-03-20 (金) 22:08:00