{"id":809,"date":"2023-08-15T23:18:03","date_gmt":"2023-08-15T15:18:03","guid":{"rendered":"http:\/\/gjweb.top\/?p=809"},"modified":"2023-08-15T23:19:09","modified_gmt":"2023-08-15T15:19:09","slug":"node-%e8%bf%9e%e6%8e%a5%e6%95%b0%e6%8d%ae%e5%ba%93%e6%8a%a5%e9%94%99%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=809","title":{"rendered":"node \u8fde\u63a5MySQL\u6570\u636e\u5e93\u62a5\u9519\u95ee\u9898"},"content":{"rendered":"\n<p>\u5148\u8d34\u51fa node \u8fde\u63a5\u6c60\u7684\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn add mysql -s<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* \u521b\u5efa\u4e00\u4e2a\u6570\u636e\u5e93\u8fde\u63a5 *\/<br>const db = mysql.createPool({<br> &nbsp;host: '114.115.218.xx',<br> &nbsp;port: \"3306\",<br> &nbsp;user: 'root',<br> &nbsp;password: \"xxx\",<br> &nbsp;database: 'xxx'<br>});<br>db.getConnection((err, connection) =&gt; {<br> &nbsp;if(err) {<br> &nbsp; &nbsp;console.log(\"\u8fde\u63a5\u5931\u8d25\")<br> &nbsp; &nbsp;console.log(err);<br>  }else{<br> &nbsp; &nbsp;console.log(\"\u8fde\u63a5\u6210\u529f\")<br>  }<br>})<\/code><\/pre>\n\n\n\n<p>\u573a\u666f\u8bf4\u660e\uff1anode \u4e2d\u672c\u5730\u6570\u636e\u8fde\u63a5\u6210\u529f\uff0c\u8fdc\u7a0b\u6570\u636e\u5e93\u8fde\u63a5\u5931\u8d25\uff0c\u4f46\u4f7f\u7528 navicat \u8fde\u63a5\u8fdc\u7a0b\u6570\u636e\u5e93\u6210\u529f\u3002<\/p>\n\n\n\n<p>node \u8fde\u63a5\u5931\u8d25\u62a5\u9519<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client <\/code><\/pre>\n\n\n\n<p>\u67e5\u627e\u8d44\u6599\u540e\u786e\u5b9a node \u8fd8\u4e0d\u652f\u6301 mysql 8.0 \u4ee5\u4e0a\u52a0\u5bc6\u65b9\u5f0f<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u89e3\u51b3\u65b9\u6848\u4e00\">\u89e3\u51b3\u65b9\u6848\u4e00\uff1a<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/*\u8fdb\u5165\u6570\u636e\u5e93*\/<br>mysql -u root -p\"\u6570\u636e\u5e93\u5bc6\u7801\";<br>\/* \u8f93\u5165\u547d\u4ee4 *\/<br>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_new_password';<br>\/* \u91cd\u542f\u670d\u52a1 *\/<br>FLUSH PRIVILEGES;<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u6267\u884c\u7b2c\u4e8c\u6761\u51fa\u73b0\u9519\u62a5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'<\/code><\/pre>\n\n\n\n<p>\u6267\u884c\u4e0b\u9762\u547d\u4ee4 \u5c06 <strong>localhost<\/strong> \u6539\u6210 <strong>%<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Gongjian_93692';<\/code><\/pre>\n\n\n\n<p>\u53c2\u8003\u5730\u5740<\/p>\n\n\n\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/50093144\/mysql-8-0-client-does-not-support-authentication-protocol-requested-by-server\">\u53c2\u8003\u6587\u68631<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/q258523454\/article\/details\/84555847\">\u53c2\u8003\u6587\u68632<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u89e3\u51b3\u65b9\u6848\u4e8c\">\u89e3\u51b3\u65b9\u6848\u4e8c<\/h2>\n\n\n\n<p>\u53ef\u4ee5\u5c1d\u8bd5\u7528 mysql2 \u66ff\u4ee3 mysql \u4f9d\u8d56\u5305<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>yarn add mysql2 --save<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.npmjs.com\/package\/mysql2\">\u5b98\u65b9\u6587\u6863<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u8d34\u51fa node \u8fde\u63a5\u6c60\u7684\u4ee3\u7801 \u573a\u666f\u8bf4\u660e\uff1anode \u4e2d\u672c\u5730\u6570\u636e\u8fde\u63a5\u6210\u529f\uff0c\u8fdc\u7a0b\u6570\u636e\u5e93\u8fde\u63a5\u5931\u8d25\uff0c\u4f46\u4f7f\u7528 navic [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66],"tags":[],"class_list":["post-809","post","type-post","status-publish","format-standard","hentry","category-mysql"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=809"}],"version-history":[{"count":2,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/809\/revisions"}],"predecessor-version":[{"id":812,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/809\/revisions\/812"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}