LoginSignup
4

More than 5 years have passed since last update.

MySQL/MariaDBのCLIコンソールのプロンプトを変更する

Last updated at Posted at 2017-09-20

いまさら感はありますが、、複数台のDBサーバを管理していると、どこに接続しているのかわからなくなるため。。

それぞれのログインで以下をコピペ

cat << '_EOT_' > ~/.my.cnf
[mysql]
prompt='\\u@\\h [\\d] >\\_'
_EOT_

ログインするとこんな感じになります

$ mysql -uuser -p -Dmy_database -hdb01.localhost.com

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.

user@db01.localhost.com [my_database] >

[参考] というか、そのまんまですが、すごくわかりやく書いてます。私はいままでこれを、my.cnfに書いていましたが、.my.cnfなんですね(汗)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4