{"id":1123,"date":"2012-12-18T14:27:59","date_gmt":"2012-12-18T05:27:59","guid":{"rendered":"http:\/\/www.techscore.com\/blog\/?p=1123"},"modified":"2018-11-14T16:33:58","modified_gmt":"2018-11-14T07:33:58","slug":"postgresql-mysql%e3%81%ab%e3%83%91%e3%82%b9%e3%83%af%e3%83%bc%e3%83%89%e5%85%a5%e5%8a%9b%e3%81%aa%e3%81%97%e3%81%a7%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.techscore.com\/blog\/2012\/12\/18\/postgresql-mysql%e3%81%ab%e3%83%91%e3%82%b9%e3%83%af%e3%83%bc%e3%83%89%e5%85%a5%e5%8a%9b%e3%81%aa%e3%81%97%e3%81%a7%e6%8e%a5%e7%b6%9a%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/","title":{"rendered":"PostgreSQL, MySQL\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u5165\u529b\u306a\u3057\u3067\u63a5\u7d9a\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"

\u3053\u3093\u306b\u3061\u306f\u3001\u6cb3\u91ce\u3067\u3059\u3002<\/p>\n

\u96c6\u8a08\u51e6\u7406\u306a\u3069\u3092\u30d0\u30c3\u30c1\u3067\u5b9f\u884c\u3059\u308b\u6642\u306b\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u305b\u305a\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3088\u306d\u3002\u3064\u3044\u3064\u3044\u5fd8\u308c\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u5099\u5fd8\u9332\u3068\u3057\u3066\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n

PostgreSQL\u306e\u5834\u5408<\/h2>\n

\u30d1\u30b9\u30ef\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb<\/strong>\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u5b9f\u884c\u30e6\u30fc\u30b6\u30fc\u306e\u30db\u30fc\u30e0\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b.pgpass<\/code>\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u3063\u3066\u3001\u305d\u306e\u4e2d\u306b\u4ee5\u4e0b\u306e\u66f8\u5f0f\u3067\u8a2d\u5b9a\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n

hostname:port:database:username:password<\/pre>\n

\u30b3\u30ed\u30f3\u3067\u533a\u5207\u3089\u308c\u305f\u30d1\u30b9\u30ef\u30fc\u30c9\u4ee5\u5916\u306e\u5404\u9805\u76ee\u306f*<\/code>\u3067\u7701\u7565\u3067\u304d\u307e\u3059\u30021\u3064\u306e\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u8907\u6570\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u7ba1\u7406\u3057\u3066\u3044\u308b\u5834\u5408\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u8a2d\u5b9a\u3092\u66f8\u304d\u8db3\u3057\u3066\u3044\u3051\u3070OK\u3067\u3059\u3002<\/p>\n

\u3053\u3093\u306a\u611f\u3058\u3067\u3059\u3002<\/p>\n

$cat $HOME\/.pgpass\r\nhost1:*:db1:kawano:hogehoge\r\nhost2:*:db2:kentaro:piyopiyo<\/pre>\n

\u3053\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u306f\u6a29\u9650\u3092600\u306b\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u6a29\u9650\u304c600\u3067\u306a\u3044\u5834\u5408\u306f\u4f7f\u7528\u3055\u308c\u307e\u305b\u3093\u3002\u30bf\u30fc\u30df\u30ca\u30eb\u4e0a\u3067psql\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u300c\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u304c\u3061\u3083\u3093\u3068\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u306a\u3044\u3088\u300d\u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u51fa\u307e\u3059\u306e\u3067\u3001\u4e8b\u524d\u306b\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n

\u307e\u305f\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3001$HOME\/.pgpass<\/code>\u3092\u53c2\u7167\u3057\u307e\u3059\u304c\u3001PGPASSFILE<\/code>\u3068\u3044\u3046\u74b0\u5883\u5909\u6570\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308c\u3070\u3001\u305d\u3061\u3089\u3092\u53c2\u7167\u3059\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

cf: PostgreSQL 9.2.0\u6587\u66f8 \u30d1\u30b9\u30ef\u30fc\u30c9\u30d5\u30a1\u30a4\u30eb<\/a><\/p>\n

MySQL\u306e\u5834\u5408<\/h2>\n

\u30e6\u30fc\u30b6\u30fc\u56fa\u6709\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u5165\u529b\u3092\u7701\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n

MySQL\u306f\u5b9f\u884c\u30e6\u30fc\u30b6\u30fc\u306e$HOME\/.my.cnf<\/code>\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3059\u308b\u306e\u3067\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u8a2d\u5b9a\u3068\u3057\u3066\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n

$ cat $HOME\/.my.cnf\r\n[client]\r\npassword=\"hogehoge\"\r\n\u305d\u306e\u4ed6\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u2026<\/pre>\n

\u3042\u304f\u307e\u3067\u3082\u8a2d\u5b9a\u3092\u8a18\u8ff0\u3059\u308b\u305f\u3081\u306e\u65b9\u6cd5\u3067\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u5c02\u7528\u3067\u306f\u306a\u3044\u3068\u3044\u3046\u3053\u3068\u306b\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n

\u307e\u305f\u3001\u3053\u3053\u3067\u8a2d\u5b9a\u3057\u3066\u3044\u308b\u30d1\u30b9\u30ef\u30fc\u30c9\u306f\u5b9f\u884c\u6642\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u30d1\u30b9\u30ef\u30fc\u30c9\u306b\u306a\u308a\u307e\u3059\u306e\u3067\u3001MySQL\u4e0a\u306e\u7570\u306a\u308b\u30e6\u30fc\u30b6\u30fc\u3092\u4f7f\u7528\u3057\u305f\u3044\u6642\u306b\u306f\u4f7f\u3048\u307e\u305b\u3093\u3002<\/p>\n

\u305d\u3093\u306a\u6642\u306b\u306f\u3001--defaults-extra-file \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u3044\u307e\u3059\u304c\u3001\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002MySQL\u3067\u306f\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u9806\u5e8f\u304c\u6c7a\u307e\u3063\u3066\u304a\u308a\u30012\u91cd\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u9805\u76ee\u306f\u3001\u5f8c\u304b\u3089\u8a2d\u5b9a\u3055\u308c\u305f\u3082\u306e\u304c\u512a\u5148\u3055\u308c\u308b\u304b\u3089\u3067\u3059\u3002<\/p>\n

defaults-extra-file \u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u6307\u5b9a\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3068\u3001.my.cnf\u3067\u306f\u3001.my.cnf\u304c\u5f8c\u304b\u3089\u8aad\u307f\u8fbc\u307e\u308c\u307e\u3059\u3002\u3069\u3061\u3089\u306b\u3082\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u3068\u3001.my.cnf\u306e\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u4f7f\u7528\u3055\u308c\u308b\u306e\u3067\u610f\u5473\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081\u306b.my.cnf\u306b\u3082\u4fee\u6b63\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n

$ cat $HOME\/.my.cnf\r\n[client]\r\n\u305d\u306e\u4ed6\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u2026<\/pre>\n
$ cat $HOME\/default-pass.my.cnf\r\n[client]\r\npassword=\"hogehoge\"<\/pre>\n
$ cat $HOME\/another-pass.my.cnf\r\n[client]\r\npassword=\"piyopiyo\"<\/pre>\n

\u30d1\u30b9\u30ef\u30fc\u30c9\u4ee5\u5916\u306b\u3082\u30012\u91cd\u306b\u8aad\u307f\u8fbc\u307e\u305b\u305f\u304f\u306a\u3044\u30aa\u30d7\u30b7\u30e7\u30f3\u304c\u3042\u308b\u5834\u5408\u306b\u306f\u3001\u305d\u308c\u3089\u3082\u5207\u308a\u5206\u3051\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n

\u5404\u30d5\u30a1\u30a4\u30eb\u306e\u8a2d\u5b9a\u304c\u3067\u304d\u305f\u3089\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n

mysql --defaults-extra-file=\/home\/kawano\/default-pass.my.cnf -u dbuser1 db1\r\nmysql --defaults-extra-file=\/home\/kawano\/another-pass.my.cnf -u dbuser2 db2<\/pre>\n

\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n

\u306a\u3093\u3060\u304b\u9762\u5012\u304f\u3055\u3044\u3067\u3059\u306d\u3002\u3044\u3063\u305d\u306e\u3053\u3068\u3001Linux\u306e\u30e6\u30fc\u30b6\u30fc\u3092\u5225\u9014\u4f5c\u3063\u3066\u3001\u305d\u308c\u305e\u308c\u306e.my.cnf\u3092\u8a2d\u5b9a\u3057\u305f\u65b9\u304c\u826f\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306d\u2026\u3002<\/p>\n

cf: MySQL :: MySQL 5.1 \u30ea\u30d5\u30a1\u30ec\u30f3\u30b9\u30de\u30cb\u30e5\u30a2\u30eb :: 3.3.2 \u30aa\u30d7\u30b7\u30e7\u30f3\u30d5\u30a1\u30a4\u30eb\u306e\u4f7f\u7528<\/a><\/p>\n

\u3069\u3061\u3089\u306b\u3082\u63a8\u5968\u3055\u308c\u3066\u3044\u306a\u3044\u65b9\u6cd5<\/h2>\n

PostgreSQL\u3067\u3082MySQL\u3067\u3082\u3001\u3042\u308b\u74b0\u5883\u5909\u6570\u306b\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\u3057\u3066\u304a\u304f\u3068\u305d\u308c\u304c\u4f7f\u7528\u3055\u308c\u308b\u3001\u3068\u3044\u3046\u8a2d\u5b9a\u304c\u3042\u308a\u307e\u3059\u3002\u63a8\u5968\u3055\u308c\u3066\u3044\u306a\u3044\u65b9\u6cd5\u3067\u3059\u306e\u3067\u3001\u4f7f\u7528\u3057\u306a\u3044\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n

\u4ee5\u4e0a\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u7701\u304f\u65b9\u6cd5\u3067\u3057\u305f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

\u3053\u3093\u306b\u3061\u306f\u3001\u6cb3\u91ce\u3067\u3059\u3002<\/p>\n

\u30d0\u30c3\u30c1\u3092\u5b9f\u884c\u3059\u308b\u6642\u306b\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u305b\u305a\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u63a5\u7d9a\u3059\u308b\u65b9\u6cd5\u3092\u307e\u3068\u3081\u3066\u307f\u307e\u3057\u305f\u3002
\u7d9a\u304d\u3092\u8aad\u3080...<\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18],"tags":[63,206,64],"_links":{"self":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/1123"}],"collection":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/comments?post=1123"}],"version-history":[{"count":1,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/1123\/revisions"}],"predecessor-version":[{"id":18002,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/posts\/1123\/revisions\/18002"}],"wp:attachment":[{"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/media?parent=1123"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/categories?post=1123"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techscore.com\/blog\/wp-json\/wp\/v2\/tags?post=1123"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}