{"id":775,"date":"2020-12-19T13:45:01","date_gmt":"2020-12-19T04:45:01","guid":{"rendered":"http:\/\/snow-cat.net\/?p=775"},"modified":"2020-12-23T20:25:26","modified_gmt":"2020-12-23T11:25:26","slug":"mysqlde","status":"publish","type":"post","link":"https:\/\/snow-cat.net\/?p=775","title":{"rendered":"Laravel\u306e\u81ea\u52d5\u30c6\u30b9\u30c8\u3092MySQL\u3067\u884c\u3046\u65b9\u6cd5"},"content":{"rendered":"<p>\u958b\u767a\u304c\u3072\u3068\u6bb5\u843d\u3057\u3066\u304d\u305f\u3086\u304d\u306d\u3053\u3067\u3059\u3002<\/p>\n<p>\u305d\u308d\u305d\u308d\u81ea\u52d5\u30c6\u30b9\u30c8\u5165\u308c\u305f\u3044\u3088\u306d\u30fc\u3068\u3044\u3046\u3053\u3068\u3067\u81ea\u52d5\u30c6\u30b9\u30c8\u3092\u3084\u308d\u3046\u3068\u3057\u305f\u3089\u5f15\u3063\u304b\u304b\u3063\u305f\u308a\u3057\u305f\u306e\u3067\u66f8\u3044\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>datebase\u306e\u554f\u984c<\/h2>\n<p>\u307e\u305a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u554f\u984c\u3067\u3059\u3088\u306d\u3002<\/p>\n<p>\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3067DB\u304c\u6c5a\u67d3\u3055\u308c\u306a\u3044\u304b\u3068\u304b\u3001\u30c7\u30fc\u30bf\u304c\u521d\u671f\u5316\u3057\u306a\u3044\u304b\u3068\u304b\u3002<\/p>\n<p>\u3053\u306e\u554f\u984c\u306e\u89e3\u6c7a\u65b9\u6cd5\u306f2\u3064\u3042\u308a\u307e\u3059\u3002<\/p>\n<h3><span>DatabaseTransactions\u3092\u4f7f\u7528\u3059\u308b<\/span><\/h3>\n<p>artisan\u3067\u30c6\u30b9\u30c8\u3092\u4f5c\u6210\u3059\u308b\u3068\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u3053\u306e\u30c6\u30b9\u30c8\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<div>\n<div>\n<pre class=\"lang:default decode:true \">use Illuminate\\Foundation\\Testing\\RefreshDatabase;<\/pre>\n<p>\u3053\u3061\u3089\u306a\u306e\u3067\u3059\u304c\u3001\u30c6\u30b9\u30c8\u304c\u7d42\u308f\u3063\u305f\u3089migration\u3092\u884c\u3046\u30e2\u30b8\u30e5\u30fc\u30eb\u306a\u3093\u3067\u3059\u306d\u3002<\/p>\n<\/div>\n<div>\u958b\u767a\u74b0\u5883\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3067\u30c6\u30b9\u30c8\u3059\u308b\u3068\u306a\u308b\u3068\u3001\u30c6\u30b9\u30c8\u304c\u7d42\u308f\u3063\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u30c7\u30fc\u30bf\u304c\u98db\u3073\u307e\u3059\u3002<\/div>\n<div>\u306a\u306e\u3067\u3001\u30c6\u30b9\u30c8\u306e\u9593\u3060\u3051\u6709\u52b9\u306a\u30c8\u30e9\u30f3\u30b6\u30af\u30b7\u30e7\u30f3\u3092\u4f5c\u3063\u3066\u304f\u308c\u308b\u4ee5\u4e0b\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u5909\u66f4\u3057\u3066\u3042\u3052\u308b\u3068\u30c6\u30b9\u30c8\u304c\u7d42\u308f\u3063\u3066\u3082\u30c7\u30fc\u30bf\u306f\u5143\u306e\u307e\u307e\u3067\u3059\u3002<\/div>\n<\/div>\n<div>\n<div>\n<pre class=\"lang:default decode:true \">use Illuminate\\Foundation\\Testing\\DatabaseTransactions;<\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<h3>\u7570\u306a\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u7528\u3059\u308b<\/h3>\n<p>\u6b21\u306b\u3001\u7570\u306a\u308b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f7f\u7528\u3059\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n<p>\u4e88\u3081hogehoge_test\u306e\u3088\u3046\u306aDB\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3092\u3001.env.testing\u306e\u3088\u3046\u306a\u30c6\u30b9\u30c8\u7528\u306e.env\u3092\u4f5c\u6210\u3057\u3066\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\" title=\".env.testing\">DB_CONNECTION=mysql\r\nDB_HOST=\r\nDB_PORT=\r\nDB_DATABASE=\r\nDB_USERNAME=\r\nDB_PASSWORD=<\/pre>\n<p>\u3053\u3046\u3059\u308c\u3070\u305d\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c7\u30fc\u30bf\u306f\u304a\u304b\u3057\u304f\u306a\u3063\u3066\u3082\u521d\u671f\u5316\u3059\u308c\u3070\u3044\u3044\u3060\u3051\u3067\u3059\u306d\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3053\u306e\u65b9\u6cd5\u3067\u30c6\u30b9\u30c8\u3092\u3059\u308b\u3053\u3068\u306b\u306a\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u4f55\u70b9\u304b\u5f15\u3063\u304b\u304b\u3063\u305f\u3068\u3053\u308d\u304c\u3042\u3063\u305f\u306e\u3067\u8a18\u8f09\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<h4>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30a8\u30e9\u30fc<\/h4>\n<p>\u958b\u767a\u3067\u306fdocker\u3092\u4f7f\u7528\u3057\u3066\u3044\u308b\u306e\u3067\u3059\u304c\u3001docker\u306e\u4e2d\u306b\u5165\u3089\u306a\u3044\u3067\u30ed\u30fc\u30ab\u30eb\u30db\u30b9\u30c8\u3067\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u51fa\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known<\/pre>\n<p>docker exec hogehoge \/bin\/bash\u306a\u3069\u3067\u4e2d\u306b\u5165\u3063\u3066\u304b\u3089\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h4>database\u304c\u5b58\u5728\u3057\u306a\u3044<\/h4>\n<p>\u6b21\u306b\u3001\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">Illuminate\\Database\\QueryException: SQLSTATE[HY000] [1049] Unknown database 'hogehoge_test' (SQL:<\/pre>\n<p>\u898b\u308c\u3070\u308f\u304b\u308b\u69d8\u306b\u3001hogehoge_test\u3068\u3044\u3046\u30c6\u30fc\u30d6\u30eb\u306f\u5b58\u5728\u3057\u306a\u3044\u3068\u3044\u3046\u30e1\u30c3\u30bb\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<p>\u4eca\u56de\u3001\u81ea\u52d5\u30c6\u30b9\u30c8\u3092\u884c\u3046\u305f\u3081\u306bhogehoge_test\u3068\u3044\u3046\u30c6\u30fc\u30d6\u30eb\u3092\u8a2d\u5b9a\u3057\u305f\u306e\u3067\u3001\u4f5c\u3063\u3066\u306a\u304b\u3063\u305f\u3089\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3059\u3002<\/p>\n<p>\u5fd8\u308c\u305a\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u3063\u3066\u3042\u3052\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u3001mysql\u306b\u5165\u3063\u3066\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3064\u3060\u3051\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">create database hogehoge_test;<\/pre>\n<h4>table\u304c\u5b58\u5728\u3057\u306a\u3044<\/h4>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u4f5c\u6210\u3057\u3066\u3082\u3001\u30b9\u30ad\u30fc\u30de\u3092\u8a2d\u5b9a\u3057\u306a\u304b\u3063\u305f\u3089\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">Illuminate\\Database\\QueryException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'hogehoge_test.user' doesn't exist (SQL:  hogehoge<\/pre>\n<p>hogehoge_test\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306buser\u306a\u3093\u3066\u30c6\u30fc\u30d6\u30eb\u306a\u3044\u3088\u3063\u3066\u30a8\u30e9\u30fc\u3067\u3059\u3002<\/p>\n<p>sql dump\u3057\u3066\u65e2\u5b58\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30b9\u30ad\u30fc\u30de\u3092\u5199\u3057\u3066\u3042\u3052\u307e\u3057\u3087\u3046\u3002<\/p>\n<div>\n<div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u958b\u767a\u304c\u3072\u3068\u6bb5\u843d\u3057\u3066\u304d\u305f\u3086\u304d\u306d\u3053\u3067\u3059\u3002 \u305d\u308d\u305d\u308d\u81ea\u52d5\u30c6\u30b9\u30c8\u5165\u308c\u305f\u3044\u3088\u306d\u30fc\u3068\u3044\u3046\u3053\u3068\u3067\u81ea\u52d5\u30c6\u30b9\u30c8\u3092\u3084\u308d\u3046 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[20],"tags":[],"class_list":["post-775","post","type-post","status-publish","format-standard","hentry","category-php"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/sattVc-mysqlde","jetpack-related-posts":[{"id":1327,"url":"https:\/\/snow-cat.net\/?p=1327","url_meta":{"origin":775,"position":0},"title":"\u81ea\u52d5\u30c6\u30b9\u30c8\u3092Laravel\u3067\u66f8\u304f\u3068\u304d\u306e\u30b3\u30c4","author":"hiro","date":"2022\u5e742\u67082\u65e5","format":false,"excerpt":"\u81ea\u52d5\u30c6\u30b9\u30c8\u3092\u65e9\u304f\u3067\u66f8\u3051\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u304d\u305f\u306e\u3067\u3001\u30b3\u30c4\u3067\u3082\u7d39\u4ecb\u3057\u3088\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002 \u4eca\u56de\u306f\u30b3\u30de\u30f3\u30c9\u306e\u30c6\u30b9\u2026","rel":"","context":"\u305d\u306e\u4ed6\u3082\u308d\u3082\u308d","block_context":{"text":"\u305d\u306e\u4ed6\u3082\u308d\u3082\u308d","link":"https:\/\/snow-cat.net\/?cat=1"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1348,"url":"https:\/\/snow-cat.net\/?p=1348","url_meta":{"origin":775,"position":1},"title":"firestore\u306e\u8003\u5bdf","author":"hiro","date":"2022\u5e743\u670819\u65e5","format":false,"excerpt":"\u6700\u8fd1firestore\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u8abf\u3079\u3066\u305f\u306e\u3067\u8003\u5bdf\u3067\u3059\u3002 \u8003\u5bdf\u306e\u307e\u3068\u3081 \u8003\u5bdf\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u2026","rel":"","context":"DB\u8a2d\u8a08","block_context":{"text":"DB\u8a2d\u8a08","link":"https:\/\/snow-cat.net\/?cat=19"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1291,"url":"https:\/\/snow-cat.net\/?p=1291","url_meta":{"origin":775,"position":2},"title":"Laravel\u306e\u30c6\u30b9\u30c8\u3067\u767a\u751f\u3057\u305f\u30a8\u30e9\u30fc","author":"hiro","date":"2021\u5e7411\u670822\u65e5","format":false,"excerpt":"Laravel\u3067\u30c6\u30b9\u30c8\u66f8\u3044\u3066\u3044\u305f\u3089\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u306e\u3067\u3001\u539f\u56e0\u3068\u89e3\u6c7a\u65b9\u6cd5\u3092\u8a18\u8f09\u3057\u3066\u304a\u304d\u307e\u3059\u3002 \u4eca\u56de\u8d77\u2026","rel":"","context":"PHP","block_context":{"text":"PHP","link":"https:\/\/snow-cat.net\/?cat=20"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":615,"url":"https:\/\/snow-cat.net\/?p=615","url_meta":{"origin":775,"position":3},"title":"Mac\u3067Laravel\u3092\u8a66\u3059\u969b\u306bsqlite\u3092\u4f7f\u7528\u3059\u308b\u8a2d\u5b9a","author":"hiro","date":"2020\u5e748\u67088\u65e5","format":false,"excerpt":"\u524d\u8077\u306fJava\u3068Python\u3060\u3063\u305f\u306e\u3067\u4e45\u3057\u3076\u308a\u306ePHP\u3092\u3084\u308b\u3053\u3068\u306b\u306a\u308a\u61d0\u304b\u3057\u3055\u3092\u611f\u3058\u3066\u308b\u3086\u304d\u306d\u3053\u3067\u3059\u2026","rel":"","context":"PHP","block_context":{"text":"PHP","link":"https:\/\/snow-cat.net\/?cat=20"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/snow-cat.net\/wp-content\/uploads\/2020\/08\/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88-2020-08-08-20.20.21-300x56.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1094,"url":"https:\/\/snow-cat.net\/?p=1094","url_meta":{"origin":775,"position":4},"title":"\u898b\u6368\u3066\u3089\u308c\u308b\u65b0\u4eba\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u884c\u52d5","author":"hiro","date":"2021\u5e748\u670825\u65e5","format":false,"excerpt":"\u79c1\u306f\u524d\u8077\u3067\u4eba\u304c\u3044\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u4f7f\u3048\u306a\u3044\u3084\u3064\u3067\u3082\u3068\u308a\u3042\u3048\u305a\u80b2\u3066\u308b\u3063\u3066\u3044\u3046\u306e\u304c\u30e2\u30c3\u30c8\u30fc\u306a\u306e\u3067\u3059\u304c\u3001\u6700\u8fd1\u6559\u2026","rel":"","context":"\u305d\u306e\u4ed6\u3082\u308d\u3082\u308d","block_context":{"text":"\u305d\u306e\u4ed6\u3082\u308d\u3082\u308d","link":"https:\/\/snow-cat.net\/?cat=1"},"img":{"alt_text":"","src":"https:\/\/ir-jp.amazon-adsystem.com\/e\/ir?t=snowcat043-22&language=ja_JP&l=li3&o=9&a=429711061X","width":350,"height":200},"classes":[]},{"id":246,"url":"https:\/\/snow-cat.net\/?p=246","url_meta":{"origin":775,"position":5},"title":"vue.js\u3092\u4e00\u304b\u3089\u8a2d\u5b9a\u3059\u308b","author":"hiro","date":"2019\u5e746\u670830\u65e5","format":false,"excerpt":"\u3053\u3093\u306b\u3061\u308f\u3001\u3086\u304d\u306d\u3053\u3067\u3059\u3002 \u6700\u8fd1vue.js\u306e\u74b0\u5883\u69cb\u7bc9\u3092\u884c\u306a\u3063\u3066\u3044\u305f\u306e\u3067\u9806\u756a\u3092\u307e\u3068\u3081\u3088\u3046\u3068\u601d\u3044\u307e\u3059\u3002\u2026","rel":"","context":"\u305d\u306e\u4ed6\u3082\u308d\u3082\u308d","block_context":{"text":"\u305d\u306e\u4ed6\u3082\u308d\u3082\u308d","link":"https:\/\/snow-cat.net\/?cat=1"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/snow-cat.net\/index.php?rest_route=\/wp\/v2\/posts\/775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/snow-cat.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/snow-cat.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/snow-cat.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/snow-cat.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=775"}],"version-history":[{"count":12,"href":"https:\/\/snow-cat.net\/index.php?rest_route=\/wp\/v2\/posts\/775\/revisions"}],"predecessor-version":[{"id":781,"href":"https:\/\/snow-cat.net\/index.php?rest_route=\/wp\/v2\/posts\/775\/revisions\/781"}],"wp:attachment":[{"href":"https:\/\/snow-cat.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/snow-cat.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/snow-cat.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}