{"id":1650,"date":"2023-03-25T21:50:34","date_gmt":"2023-03-25T13:50:34","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1650"},"modified":"2023-04-23T21:57:07","modified_gmt":"2023-04-23T13:57:07","slug":"magento-access-mongodb","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/25\/magento-access-mongodb\/","title":{"rendered":"Magento\u63a5\u5165MongoDB"},"content":{"rendered":"<p>MongoDB\u662f\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93(nosql)\uff0c\u5c5e\u4e8e\u6587\u6863\u578b\u6570\u636e\u5e93\u3002<br \/>\n\u53ef\u4ee5\u66ff\u4ee3MySQL\uff0c\u4f46\u4e0d\u5efa\u8bae\u3002\u539f\u56e0\u5f53\u7136\u4e0d\u6b62\u4e0d\u652f\u6301\u4e8b\u52a1\u4e00\u4e2a\uff0c\u4f46\u662f\u5355\u5355\u8fd9\u4e00\u4e2a\uff0c\u5c31\u4f7f\u5f97MongoDB\u65e0\u6cd5\u5b8c\u5168\u53d6\u4ee3MySQL\u3002<br \/>\n\u4e2a\u4eba\u4e00\u822c\u5728\u4e1a\u52a1\u6bd4\u8f83\u5355\u4e00\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528MongoDB\uff0c\u6bd4\u5982\u65e5\u5fd7\u8bb0\u5f55\u3002<\/p>\n<h2>\u5b89\u88c5mongodb<\/h2>\n<p><!-- more --><\/p>\n<p>\u5b98\u65b9\u6587\u6863\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/docs.mongodb.com\/manual\/tutorial\/install-mongodb-on-red-hat\/\">https:\/\/docs.mongodb.com\/manual\/tutorial\/install-mongodb-on-red-hat\/<\/a><\/p>\n<pre><code class=\"language-bash\"># vim \/etc\/yum.repos.d\/mongodb-org-4.2.repo\n\n[mongodb-org-4.2]\nname=MongoDB Repository\nbaseurl=https:\/\/repo.mongodb.org\/yum\/redhat\/$releasever\/mongodb-org\/4.2\/x86_64\/\ngpgcheck=1\nenabled=1\ngpgkey=https:\/\/www.mongodb.org\/static\/pgp\/server-4.2.asc<\/code><\/pre>\n<pre><code class=\"language-bash\"># sudu yum install -y mongodb-org\n### \u6307\u5b9a\u7248\u672c\u5e76\u7981\u6b62\u81ea\u52a8\u5347\u7ea7\u3002\u4e0e\u4e0a\u4e00\u6761\u547d\u4ee4\u4e8c\u9009\u4e00\u5373\u53ef\n# sudo yum install -y mongodb-org-4.2.5 mongodb-org-server-4.2.5 mongodb-org-shell-4.2.5 mongodb-org-mongos-4.2.5 mongodb-org-tools-4.2.5\n# vim \/etc\/yum.conf\nexclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools\n### \u542f\u52a8\uff0c\u505c\u6b62\uff0c\u91cd\u542f\u670d\u52a1\nservice mongod start\nservice mongod stop\nservice mongod restart<\/code><\/pre>\n<h2>\u914d\u7f6emongodb<\/h2>\n<p>\u4e00\u822c\u4f7f\u7528\u9ed8\u8ba4\u914d\u7f6e\u5373\u53ef\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.yezhou.me\/AppBlog\/images\/PHP\/MongoDB\u914d\u7f6e.png\" alt=\"Magento MongoDB\u914d\u7f6e\" \/><\/p>\n<p>\uff081\uff09\u5982\u679c\u5355\u673a\uff0cbindIp\u7528127.0.0.1\uff0c\u63d0\u9ad8\u5b89\u5168\u6027\uff1b\u5982\u679cweb\u670d\u52a1\u548cmongodb\u4e0d\u5728\u540c\u4e00\u53f0\u670d\u52a1\u5668\uff0cbindIp\u75280.0.0.0\u3002\u53ea\u80fd\u4e8c\u9009\u4e00\uff0c\u5176\u5b83\u90fd\u4f1a\u5bfc\u81f4\u91cd\u542f\u5931\u8d25\uff08\u7f51\u4e0a\u63d0\u4f9b\u7684\u7ed1\u5b9a\u5185\u7f51IP\u5e76\u6ca1\u6709\u7528\uff09\u3002\u8003\u8651\u5b8c\u5168\u7684\u8bdd\uff0c\u53ef\u4ee5\u914d\u5408\u670d\u52a1\u5668\u9632\u706b\u5899\uff0c\u53ea\u5141\u8bb8\u6307\u5b9aIP\u8bbf\u95eemongodb\u7ed1\u5b9a\u7aef\u53e3\u3002<br \/>\n\uff082\uff09\u542f\u7528\u9a8c\u8bc1\u3002\u9700\u8981\u5148\u8fdb\u5165mongodb\u521b\u5efa\u7ba1\u7406\u5458\u8d26\u53f7\uff0c\u518d\u4fee\u6539\u914d\u7f6e\uff0c\u7136\u540e\u91cd\u542fmongodb\u3002<\/p>\n<pre><code class=\"language-bash\">### \u8fdb\u5165mongo\n# mongo\n# \u5207\u6362db\uff0c\u521b\u5efa\u7528\u6237\nuse admin\ndb.createUser({ user:&quot;yezhou&quot;,  pwd:&quot;123456&quot;,  roles:[\n{role: &quot;root&quot;, db: &quot;admin&quot;}\n]})\n\n### \u4fee\u6539\u914d\u7f6e\n# vim \/etc\/mongod.conf   \nsecurity:   \n  authorization: enabled\n\n### \u91cd\u542fmongo  \n# service mongod restart<\/code><\/pre>\n<h2>\u5b89\u88c5php\u6269\u5c55<\/h2>\n<pre><code class=\"language-bash\">yum -y install openssl openssl-devel\nwget https:\/\/pecl.php.net\/get\/mongodb-1.8.0.tgz\ntar zxf mongodb-1.8.0.tgz \ncd mongodb-1.8.0\n\/usr\/bin\/phpize\n.\/configure --with-php-config=\/usr\/bin\/php-config &amp;&amp; make &amp;&amp; make install<\/code><\/pre>\n<pre><code class=\"language-bash\"># \u5728php.ini\u52a0\u4e0a\u6269\u5c55\nextension=mongodb.so\n\n# \u91cd\u542fphp-fpm\nservice php-fpm restart<\/code><\/pre>\n<h2>\u4f7f\u7528mongodb<\/h2>\n<p>\u4e3a\u4e86\u80fd\u5728php\u9879\u76ee\u4e2d\u4f7f\u7528mongodb\u6267\u884ccurd\u64cd\u4f5c\uff0c\u8fd8\u9700\u8981\u5148\u5728\u9879\u76ee\u6839\u76ee\u5f55\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-bash\">composer require mongodb\/mongodb<\/code><\/pre>\n<p>\u5177\u4f53\u7684\u8bed\u6cd5\u8fd9\u91cc\u5c31\u4e0d\u591a\u8bf4\u4e86\uff0cMongodb\u7684\u5b89\u88c5\u914d\u7f6e\u5230\u8fd9\u91cc\u4e5f\u5c31\u7ed3\u675f\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB\u662f\u975e\u5173\u7cfb\u578b\u6570\u636e\u5e93(nosql)\uff0c\u5c5e\u4e8e\u6587\u6863\u578b\u6570\u636e\u5e93\u3002 \u53ef\u4ee5\u66ff\u4ee3MySQL\uff0c\u4f46\u4e0d\u5efa\u8bae\u3002\u539f\u56e0\u5f53\u7136\u4e0d\u6b62\u4e0d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[78],"tags":[154],"class_list":["post-1650","post","type-post","status-publish","format-standard","hentry","category-magento","tag-mongodb"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1650"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1650\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}