{"id":1057,"date":"2022-01-05T18:09:34","date_gmt":"2022-01-05T10:09:34","guid":{"rendered":"https:\/\/104.es\/?p=1057"},"modified":"2022-01-05T18:09:34","modified_gmt":"2022-01-05T10:09:34","slug":"laravel-sqlite","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2022\/01\/05\/laravel-sqlite\/","title":{"rendered":"\u5728Laravel\u7db2\u7ad9\u4e2d\u4f7f\u7528SQLite\u8cc7\u6599\u5eab"},"content":{"rendered":"\n<p>\u540c\u6a23\u7684\uff0c\u5982\u679c\u4f60\u7684\u7db2\u7ad9\u53ea\u662f\u7528\u4f86\u6e2c\u8a66\u7528\u7684\u5c0f\u7db2\u7ad9\uff0c\u4e0d\u592a\u9700\u8981\u4f7f\u7528\u5230\u592a\u591a\u7684\u8cc7\u6599\u5eab\u64cd\u4f5c\u7684\u8a71\uff0c\u8207\u5176\u5f88\u9ebb\u7169\u5730\u53bb\u627e\u4e00\u500b\u53ef\u4ee5\u4f7f\u7528MySQL\u4f3a\u670d\u5668\uff0c\u9084\u4e0d\u5982\u5c31\u76f4\u63a5\u4f7f\u7528\u6a94\u6848\u578b\u8cc7\u6599\u5eabSQLite\u5c31\u597d\u4e86\u3002\u57fa\u672c\u4e0a\uff0c\u5b83\u5c31\u662f\u4e00\u500b\u6a94\u6848\u800c\u5df2\u3002<\/p>\n\n\n\n<p>\u7576\u6211\u5011\u5efa\u7acb\u4e86\u4e00\u500bLaravel\u7db2\u7ad9\u6846\u67b6\u4e4b\u5f8c\uff0c\u5728\u9810\u8a2d\u7684\u60c5\u5f62\u4e0b\u5b83\u4f7f\u7528\u7684\u662fMySQL\u4f3a\u670d\u5668\uff0c\u5982\u679c\u8981\u628a\u5b83\u6539\u70baSQLite\u7684\u8a71\uff0c\u9996\u5148\u4e5f\u662f\u5229\u7528DB Browser for SQLite\u65b0\u5efa\u4e00\u500b\u7a7a\u7684\u8cc7\u6599\u5eab\u6a94\u6848\uff0c\u53eb\u505adatabase.sqlite\uff0c\u88e1\u9762\u90fd\u4e0d\u8981\u7522\u751f\u4efb\u4f55\u7684\u8cc7\u6599\u8868\uff0c\u76f4\u63a5\u628a\u9019\u500b\u6a94\u6848\u8907\u88fd\u5230Laravel \u6846\u67b6\u4e2d\u7684database\u8cc7\u6599\u593e\u88e1\u9762\u3002<\/p>\n\n\n\n<p>\u4e0b\u4e00\u6b65\u662f\u5230config\u8cc7\u6599\u593e\u4e0b\uff0c\u627e\u51fadatabase.php\u9019\u500b\u6a94\u6848\uff0c\u627e\u5230\u4ee5\u4e0b\u9019\u884c\u8a2d\u5b9a\u6307\u4ee4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'database' =&gt; env('DB_DATABASE', database_path('database.sqlite')),<\/code><\/pre>\n\n\n\n<p>\u628a\u5b83\u6539\u70ba\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>'database' =&gt; database_path(env('DB_DATABASE')),<\/code><\/pre>\n\n\n\n<p>\u6700\u5f8c\uff0c\u5230.env\u9019\u500b\u8a2d\u5b9a\u6a94\u6848\u4e2d\u6709\u95dc\u65bc\u8cc7\u6599\u5eab\u7684\u8a2d\u5b9a\uff0c\u628a\u5b83\u8abf\u6574\u6210\u5982\u4e0b\u6240\u793a\u7684\u5167\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DB_CONNECTION=sqlite\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=database.sqlite\nDB_USERNAME=\nDB_PASSWORD=<\/code><\/pre>\n\n\n\n<p>\u7136\u5f8c\u5c31\u5b8c\u6210\u4e86\u6240\u9700\u8981\u7684\u8a2d\u5b9a\u4e86\uff0c\u4e4b\u5f8c\u5728\u9032\u884c\u8cc7\u6599\u5eab\u5b58\u53d6\u6642\uff0c\u548c\u4e4b\u524d\u4f7f\u7528MySQL\u8cc7\u6599\u5eab\u7cfb\u7d71\u6642\u4e26\u6c92\u6709\u4efb\u4f55\u7684\u5dee\u5225\u3002\u4fee\u6539\u5b8c\u7562\u4e4b\u5f8c\uff0c\u53ef\u4ee5\u5229\u7528\u4ee5\u4e0b\u7684\u6307\u4ee4\u9032\u884c\u8cc7\u6599\u5eab\u9077\u79fb\u4f5c\u696d\uff0c\u5982\u679c\u80fd\u5920\u6210\u529f\u57f7\u884c\u5c31\u8868\u793a\u4e00\u5207OK\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan migrate<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u540c\u6a23\u7684\uff0c\u5982\u679c\u4f60\u7684\u7db2\u7ad9\u53ea\u662f\u7528\u4f86\u6e2c\u8a66\u7528\u7684\u5c0f\u7db2\u7ad9\uff0c\u4e0d\u592a\u9700\u8981\u4f7f\u7528\u5230\u592a\u591a\u7684\u8cc7\u6599\u5eab\u64cd\u4f5c\u7684\u8a71\uff0c\u8207\u5176\u5f88\u9ebb\u7169\u5730\u53bb\u627e\u4e00\u500b\u53ef\u4ee5\u4f7f\u7528MySQL\u4f3a\u670d\u5668\uff0c\u9084\u4e0d\u5982\u5c31\u76f4\u63a5\u4f7f\u7528\u6a94\u6848\u578b\u8cc7\u6599\u5eabSQLite\u5c31\u597d\u4e86\u3002\u57fa\u672c\u4e0a\uff0c\u5b83\u5c31\u662f\u4e00\u500b\u6a94\u6848\u800c\u5df2\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[21,14],"tags":[],"class_list":["post-1057","post","type-post","status-publish","format-standard","hentry","category-laravel","category-php"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1057","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=1057"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1057\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=1057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=1057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=1057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}