LoginSignup
19
7

More than 5 years have passed since last update.

mysqlのクライアントmycliが便利だった。

Posted at

mycliとは?

https://www.mycli.net/

mysqlクライアントです。公式サイトみてもらうとわかるんですが、
基本コマンドには補完が聞くし、テーブル名とかも補完候補に自動で入ってくるので変なtypoがなくなってすごい楽に。
あとは、カラースキーマ、個別の色設定も諸々できる感じ。

スクリーンショット 2019-01-25 19.38.46

インストール方法

$ pip install mycli

もしくは

$ brew update && brew install mycli

使い方

mysqlコマンドと一緒で例えばローカルのmysqlに繋ぐ場合

$ mycli -uroot -p -h127.0.0.1 -P 3306

みたいな感じにするとmycliのコンソールが開きます。
あとは使い方はmysqlと一緒。

色の設定を変更する

https://www.mycli.net/syntax

設定ファイルが ~/.myclircにできているので、
その中身のsyntax部分を好みのものに変更します。

# Syntax coloring style. Possible values (many support the "-dark" suffix):
# manni, igor, xcode, vim, autumn, vs, rrt, native, perldoc, borland, tango, emacs,
# friendly, monokai, paraiso, colorful, murphy, bw, pastie, paraiso, trac, default,
# fruity.
# Screenshots at http://mycli.net/syntax
syntax_style = monokai

結果をファイルに保存

> ¥o filename
> select * from table;

これだけでselectの結果をfileに落とすことができたりします。
この他にもいろいろとコマンドがある。

https://www.mycli.net/commands

mysqlコンソールで試したやつをファイルにしたかった場合、mysqlコマンドをコピーして、別にシェルを用意、もしくは-eで実行とかやってたんですが、
mycli使うとその辺の手間がなくなる感じです。しばらく使ってみよう。

19
7
1

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