2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MySQLのSQLをシェルから実行したい

Last updated at Posted at 2013-07-12

シェルでSQLの値を受け取ってawkに渡したい時とかに使う

mysql -uroot -p[password] -e "show databases"
 +--------------------+
 | Database           |
 +--------------------+
 | information_schema |
 | fuck               |
 | mysql              |
 | performance_schema |
 +--------------------+

-pの後にパスワード直接打つと、「非表示にしてないのにパスワード直接シェルに打ち込むとか馬鹿なの??」ってwarningが出る。-pだけ指定してその後にパスワード打ち込む事も可能。

-eだとカラム名とか余計なものまで表示されちゃう。-Nオプションをつければそれの抑制も可能。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?