{"id":30,"date":"2024-02-19T10:18:35","date_gmt":"2024-02-19T10:18:35","guid":{"rendered":"http:\/\/localhost\/w643\/?p=30"},"modified":"2024-03-19T02:29:16","modified_gmt":"2024-03-19T02:29:16","slug":"bai-2-connect-toi-database","status":"publish","type":"post","link":"https:\/\/blog.hnk90.com\/?p=30","title":{"rendered":"B\u00e0i 2. Connect t\u1edbi Database"},"content":{"rendered":"\n<p>Sau khi \u0111\u00e3 c\u00e0i \u0111\u1eb7t xong d\u1ef1 \u00e1n th\u00ec ch\u00fang ta s\u1ebd t\u1ea1o database v\u00e0 config v\u1edbi laravel nh\u00e1.<br>M\u00ecnh s\u1eed d\u1ee5ng tool dbeaver \u0111\u1ec3 qu\u1ea3n l\u00fd database (b\u1ea3n CE nha m\u1ecdi ng\u01b0\u1eddi <a href=\"https:\/\/dbeaver.io\/\">https:\/\/dbeaver.io\/<\/a>)<\/p>\n\n\n\n<p>Ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng mysql l\u00e0m database engine.<\/p>\n\n\n\n<p>Step 1. T\u1ea1o database<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"396\" height=\"278\" src=\"http:\/\/localhost\/w643\/wp-content\/uploads\/2024\/02\/2024-02-19_09-26.png\" alt=\"\" class=\"wp-image-31\" srcset=\"https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/02\/2024-02-19_09-26.png 396w, https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/02\/2024-02-19_09-26-300x211.png 300w\" sizes=\"auto, (max-width: 396px) 100vw, 396px\" \/><\/figure>\n\n\n\n<p>Step 2. Config database<\/p>\n\n\n\n<p>T\u1ea1i root folder s\u1ebd c\u00f3 file .env, c\u00e1c b\u1ea1n config nh\u01b0 sau<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"246\" height=\"187\" src=\"http:\/\/localhost\/w643\/wp-content\/uploads\/2024\/02\/2024-02-19_10-10.png\" alt=\"\" class=\"wp-image-32\"\/><\/figure>\n\n\n\n<p>Step 3. Ch\u1ea1y l\u1ec7nh sau<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#2e3440ff\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"php artisan migrate\" style=\"color:#d8dee9ff;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki nord\" style=\"background-color: #2e3440ff\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #D8DEE9\">php<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">artisan<\/span><span style=\"color: #D8DEE9FF\"> <\/span><span style=\"color: #D8DEE9\">migrate<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Step 4. Ki\u1ec3m tra<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"997\" height=\"444\" src=\"http:\/\/localhost\/w643\/wp-content\/uploads\/2024\/02\/2024-02-19_10-13.png\" alt=\"\" class=\"wp-image-33\" srcset=\"https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/02\/2024-02-19_10-13.png 997w, https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/02\/2024-02-19_10-13-300x134.png 300w, https:\/\/blog.hnk90.com\/wp-content\/uploads\/2024\/02\/2024-02-19_10-13-768x342.png 768w\" sizes=\"auto, (max-width: 997px) 100vw, 997px\" \/><\/figure>\n\n\n\n<p>H\u1ec7 th\u1ed1ng s\u1ebd t\u1ef1 \u0111\u1ed9ng generate m\u1ed9t s\u1ed1 default tables v\u00e0o trong database ch\u00fang ta t\u1ea1o ra. <\/p>\n\n\n\n<p>Nh\u01b0 v\u1eady l\u00e0 xong r\u1ed3i \u0111\u00f3. B\u00e0i ti\u1ebfp theo ch\u00fang ta s\u1ebd \u0111i t\u00ecm hi\u1ec3u m\u1ed9t s\u1ed1 l\u00fd thuy\u1ebft v\u1ec1 configuration. <\/p>\n\n\n\n<p>Have a nice day to you !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sau khi \u0111\u00e3 c\u00e0i \u0111\u1eb7t xong d\u1ef1 \u00e1n th\u00ec ch\u00fang ta s\u1ebd t\u1ea1o database v\u00e0 config v\u1edbi laravel nh\u00e1.M\u00ecnh s\u1eed d\u1ee5ng tool dbeaver \u0111\u1ec3 qu\u1ea3n l\u00fd database (b\u1ea3n CE nha m\u1ecdi ng\u01b0\u1eddi https:\/\/dbeaver.io\/) Ch\u00fang ta s\u1ebd s\u1eed d\u1ee5ng mysql l\u00e0m database engine. Step 1. T\u1ea1o database Step 2. Config database T\u1ea1i root folder s\u1ebd c\u00f3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-30","post","type-post","status-publish","format-standard","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/30","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":2,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"predecessor-version":[{"id":36,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions\/36"}],"wp:attachment":[{"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hnk90.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}