{"id":39694,"date":"2024-11-26T16:19:28","date_gmt":"2024-11-26T08:19:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/39694\/"},"modified":"2024-11-26T16:19:28","modified_gmt":"2024-11-26T08:19:28","slug":"%e5%85%a5%e9%97%a8mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e5%af%bc%e5%85%a5%e4%b8%8e%e5%af%bc%e5%87%ba%e5%8f%8a%e9%87%8d%e7%bd%aeroot%e5%af%86%e7%a0%81","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/39694\/","title":{"rendered":"\u5165\u95e8MySQL\u6570\u636e\u5e93\u5bfc\u5165\u4e0e\u5bfc\u51fa\u53ca\u91cd\u7f6eroot\u5bc6\u7801"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/172983567643251.jpg\" class=\"aligncenter\" title=\"\u5165\u95e8MySQL\u6570\u636e\u5e93\u5bfc\u5165\u4e0e\u5bfc\u51fa\u53ca\u91cd\u7f6eroot\u5bc6\u7801\u63d2\u56fe\" alt=\"\u5165\u95e8MySQL\u6570\u636e\u5e93\u5bfc\u5165\u4e0e\u5bfc\u51fa\u53ca\u91cd\u7f6eroot\u5bc6\u7801\u63d2\u56fe\" \/><\/p>\n<p><span style=\"color:#1E1E1E;letter-spacing: 2px;border-left:#FF3030 3px solid;border-right:#FF3030 3px solid;padding-left: 8px;padding-right:8px;font-size: 12pt\"><strong>\u5982\u4f55\u5bfc\u5165\u548c\u5bfc\u51fa\u6570\u636e\u5e93<\/strong><\/span>  <\/p>\n<p>\u8981\u5bfc\u51fa\u6570\u636e\u5e93\uff0c\u6253\u5f00\u7ec8\u7aef\uff0c\u786e\u4fdd\u60a8\u672a\u767b\u5f55MySQL\u5e76\u952e\u5165\uff0c<\/p>\n<pre>\nmysqldump -u [username] -p [database name] &gt; [database name].sql \n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u60a8\u5728\u547d\u4ee4\u4e2d\u9009\u62e9\u7684\u6570\u636e\u5e93\u73b0\u5728\u5c06\u5bfc\u51fa\u5230\u60a8\u7684Droplet\u3002<\/p>\n<p>\u8981\u5bfc\u5165\u6570\u636e\u5e93\uff0c\u9996\u5148\u5728MySQL shell\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7a7a\u767d\u6570\u636e\u5e93\u4f5c\u4e3a\u6570\u636e\u7684\u76ee\u6807\u3002<\/p>\n<pre>\nCREATE DATABASE newdatabase; \n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7136\u540e\u6ce8\u9500MySQL shell\uff0c\u5e76\u5728\u547d\u4ee4\u884c\u4e2d\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>\nmysql -u [username] -p newdatabase With that, your chosen database has been imported into your destination database in MySQL.  \nHow to Reset a Root Password\nWhen you first install MySQL, you have to set up your root password. However, should you forget it at any point, you can still recover it.  \nStep One\u2014Shut Down MySQL\nIn terminal, stop the MySQL process\n \/etc\/init.d\/mysql stop\nStep Two\u2014Access MySQL Safe Mode\nIn safe mode, you will be able to make changes within the MySQL system with a root password alone, without the need for MySQL root password.\nsudo mysqld_safe --skip-grant-tables &amp; Once safe mode has started up, log into MySQL and when prompted, use your standard root password.\nmysql -u root mysql\nStep Three\u2014Set Up a New Password\nFinally, set up the new MySQL root password by typing the command below. Replace \"newpassword\" with the password of your choice.\nupdate user set password=PASSWORD(\"newpassword\") where User='root'; Be sure to reload everything:\n FLUSH PRIVILEGES; and you now have a new root password.\nBy Etel Sverdlov\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6837\uff0c\u60a8\u9009\u62e9\u7684\u6570\u636e\u5e93\u5df2\u5bfc\u5165\u5230MySQL\u4e2d\u7684\u76ee\u6807\u6570\u636e\u5e93\u3002<\/p>\n<p><span style=\"color:#1E1E1E;letter-spacing: 2px;border-left:#FF3030 3px solid;border-right:#FF3030 3px solid;padding-left: 8px;padding-right:8px;font-size: 12pt\"><strong>\u5982\u4f55\u91cd\u7f6eroot\u5bc6\u7801<\/strong><\/span>  <\/p>\n<p>\u5f53\u60a8\u9996\u6b21\u5b89\u88c5MySQL\u65f6\uff0c\u60a8\u5fc5\u987b\u8bbe\u7f6eroot\u5bc6\u7801\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u5fd8\u8bb0\u5b83\u5728\u4efb\u4f55\u65f6\u5019\uff0c\u4f60\u4ecd\u7136\u53ef\u4ee5\u6062\u590d\u5b83\u3002<\/p>\n<p><span style=\"color:#1E1E1E;letter-spacing: 2px;border-left:#FF3030 3px solid;border-right:#FF3030 3px solid;padding-left: 8px;padding-right:8px;font-size: 12pt\"><strong>\u7b2c\u4e00\u6b65 &#8211; \u5173\u95edMySQL<\/strong><\/span>  <\/p>\n<p>\u5728\u7ec8\u7aef\u4e2d\uff0c\u505c\u6b62MySQL\u8fdb\u7a0b<\/p>\n<pre>\n \/etc\/init.d\/mysql stop\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<span style=\"color:#1E1E1E;letter-spacing: 2px;border-left:#FF3030 3px solid;border-right:#FF3030 3px solid;padding-left: 8px;padding-right:8px;font-size: 12pt\"><strong>\u7b2c\u4e8c\u6b65 &#8211; \u8bbf\u95eeMySQL\u5b89\u5168\u6a21\u5f0f<\/strong><\/span>  <\/p>\n<p>\u5728\u5b89\u5168\u6a21\u5f0f\u4e0b\uff0c\u60a8\u5c06\u80fd\u591f\u5728MySQL\u7cfb\u7edf\u4e2d\u5355\u72ec\u4f7f\u7528root\u5bc6\u7801\u8fdb\u884c\u66f4\u6539\uff0c\u800c\u65e0\u9700MySQL root\u5bc6\u7801\u3002<\/p>\n<pre>\nsudo mysqld_safe --skip-grant-tables &amp; \n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4e00\u65e6\u5b89\u5168\u6a21\u5f0f\u542f\u52a8\uff0c\u767b\u5f55MySQL\u5e76\u63d0\u793a\uff0c\u4f7f\u7528\u60a8\u7684\u6807\u51c6root\u5bc6\u7801\u3002<\/p>\n<pre>\nmysql -u root mysql\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236<br \/>\n<span style=\"color:#1E1E1E;letter-spacing: 2px;border-left:#FF3030 3px solid;border-right:#FF3030 3px solid;padding-left: 8px;padding-right:8px;font-size: 12pt\"><strong>\u7b2c\u4e09\u6b65 &#8211; \u8bbe\u7f6e\u65b0\u5bc6\u7801<\/strong><\/span>  <\/p>\n<p>\u6700\u540e\uff0c\u901a\u8fc7\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\u8bbe\u7f6e\u65b0\u7684MySQL root\u5bc6\u7801\u3002\u5c06\u201cnewpassword\u201d\u66ff\u6362\u4e3a\u60a8\u9009\u62e9\u7684\u5bc6\u7801\u3002<\/p>\n<pre>\nupdate user set password=PASSWORD(\"newpassword\") where User='root';\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p> \u4e00\u5b9a\u8981\u91cd\u65b0\u52a0\u8f7d\u4e00\u5207\uff1a<\/p>\n<pre>\n FLUSH PRIVILEGES; \n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5e76\u4e14\u60a8\u73b0\u5728\u6709\u4e00\u4e2a\u65b0\u7684root\u5bc6\u7801\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5165\u95e8MySQL\u6570\u636e\u5e93\u5bfc\u5165\u4e0e\u5bfc\u51fa\u53ca\u91cd\u7f6eroot\u5bc6\u7801\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5bfc\u5165\u548c\u5bfc\u51fa\u6570\u636e\u5e93 \u8981\u5bfc\u51fa\u6570\u636e\u5e93\uff0c\u6253\u5f00\u7ec8\u7aef\uff0c\u786e\u4fdd\u60a8\u672a\u767b\u5f55MySQL\u5e76\u952e\u5165\uff0c mysqldump -u [username] -p [database name] &gt; [database name].sql \u767b\u5f55\u540e\u590d\u5236 \u60a8\u5728\u547d\u4ee4\u4e2d\u9009\u62e9\u7684\u6570\u636e\u5e93\u73b0\u5728\u5c06\u5bfc\u51fa\u5230\u60a8\u7684Droplet\u3002 \u8981\u5bfc\u5165\u6570\u636e\u5e93\uff0c\u9996\u5148\u5728MySQL shell\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u7a7a\u767d\u6570\u636e\u5e93\u4f5c\u4e3a\u6570\u636e\u7684\u76ee\u6807\u3002 CREATE DATABASE newdatabase; \u767b\u5f55\u540e\u590d\u5236 \u7136\u540e\u6ce8\u9500MySQL shell\uff0c\u5e76\u5728\u547d\u4ee4\u884c\u4e2d\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a mysql -u [username] -p newdatabase With that, your chosen database has been imported into your destination database in MySQL. How to Reset a Root Password When you first install MySQL, you have to set [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-39694","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=39694"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39694\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=39694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=39694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=39694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}