mysqlのテーブル一覧を取得するワンライナー

公開日時

show tablesの結果をパイプでつないで1行目を削除するとテーブル一覧が取得できる。

mysql -uuser -ppass -h127.0.0.1 -P3306 dbname -e 'show tables' | sed -e '1d'

users
samples

さらにパイプでつないで|区切りで表示したりするのもできる。

mysql -uuser -ppass -h127.0.0.1 -P3306 dbname -e 'show tables' | sed -e '1d' | xargs echo | sed s/\ /\|/g

users|samples

参考


Related #mysql

Authentication plugin 'caching_sha2_password' cannot be loaded

認証プラグインをmysql_native_passwordに戻した

mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.

windowsだとvolume mountすると777になるのでDockerfileを作ってcopyするようにした

Dockerでpt-query-digestを使う

コンテナのおかげで手軽にslowlog分析ができるようになった

Sequel ProでJSON型を含むテーブルのexport/importを行う

test build版を使う必要があった

MySQLで現在時刻から○日後のデータを作る

DATE_SUB, DATE_ADDとINTERVALを組み合わせる