{"id":261,"date":"2024-07-19T10:48:02","date_gmt":"2024-07-19T02:48:02","guid":{"rendered":"https:\/\/thereisno.top:4430\/?p=261"},"modified":"2024-07-19T10:48:02","modified_gmt":"2024-07-19T02:48:02","slug":"mysql%e9%87%8d%e7%bd%aeroot%e5%af%86%e7%a0%81-2","status":"publish","type":"post","link":"https:\/\/thereisno.top\/?p=261","title":{"rendered":"mysql\u91cd\u7f6eroot\u5bc6\u7801"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-reset-your-mysql-or-mariadb-root-password#step-1-identifying-the-database-version\" data-type=\"link\" data-id=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-reset-your-mysql-or-mariadb-root-password#step-1-identifying-the-database-version\">\u82f1\u6587\u539f\u6587\u53c2\u8003\u5730\u5740<\/a><\/p>\n\n\n\n<p>1\u3001\u68c0\u67e5\u7248\u672c<br>mysql &#8211;version<br>MySQL output<\/p>\n\n\n\n<p>mysql Ver 14.14 Distrib 5.7.16, for Linux (x86_64) using EditLine wrapper<br>Or output like this for MariaDB:<\/p>\n\n\n\n<p>MariaDB output<br>mysql Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1<\/p>\n\n\n\n<p>2\u3001\u505c\u6b62\u670d\u52a1<\/p>\n\n\n\n<p>MySQL with:<br>sudosystemctl stop mysql<\/p>\n\n\n\n<p>MariaDB wtih:<br>sudosystemctl stop mariadb<\/p>\n\n\n\n<p>3\u3001\u5f00\u542f\u5b89\u5168\u6a21\u5f0f<br>sudo mysqld_safe &#8211;skip-grant-tables &#8211;skip-networking &amp;<\/p>\n\n\n\n<p>4\u3001\u4f7f\u7528root\u514d\u5bc6\u7801\u767b\u5f55<br>mysql -uroot<\/p>\n\n\n\n<p>MySQL prompt<br>Type &#8216;help;&#8217; or &#8216;\\h&#8217; for help. Type &#8216;\\c&#8217; to clear the current input statement.<br>mysql&gt;<br>MariaDB prompt<br>Type &#8216;help;&#8217; or &#8216;\\h&#8217; for help. Type &#8216;\\c&#8217; to clear the current input statement.<br>MariaDB [(none)]&gt;<\/p>\n\n\n\n<p>5\u3001FLUSH PRIVILEGES;<br><mark style=\"background-color:#fcb900\" class=\"has-inline-color\">\u975e\u5e38\u5173\u952e\uff0c\u5fc5\u987b\u5148\u6267\u884c\u8fd9\u4e2a<\/mark>\uff0c\u7136\u540e\u6267\u884c\u540e\u9762\u7684\u8bed\u53e5\u624d\u6709\u6548<\/p>\n\n\n\n<p>6\u3001\u4fee\u6539\u5bc6\u7801<br>For MySQL 5.7.6 and newer as well as MariaDB 10.1.20 and newer, use the following command.<\/p>\n\n\n\n<p>ALTER USER&#8217;root&#8217;@&#8217;localhost&#8217;IDENTIFIED BY &#8216;new_password&#8217;;<\/p>\n\n\n\n<p>For MySQL 5.7.5 and older as well as MariaDB 10.1.20 and older, use:<\/p>\n\n\n\n<p>SET PASSWORD FOR &#8216;root&#8217;@&#8217;localhost&#8217;=PASSWORD(&#8216;new_password&#8217;);<\/p>\n\n\n\n<p>\u6216\u8005<br>UPDATE mysql.user SET authentication_string =PASSWORD(&#8216;new_password&#8217;)WHERE User =&#8217;root&#8217;AND Host =&#8217;localhost&#8217;;<\/p>\n\n\n\n<p>7\u3001\u91cd\u542f<br>For MySQL, use:<br>sudokill<code>cat\/var\/run\/mysqld\/mysqld.pid<\/code><\/p>\n\n\n\n<p>For MariaDB, use:<br>sudokill<code>\/var\/run\/mariadb\/mariadb.pid<\/code><\/p>\n\n\n\n<p>Then, restart the service using systemctl.<\/p>\n\n\n\n<p>For MySQL, use:<br>sudo systemctl start mysql<\/p>\n\n\n\n<p>For MariaDB, use:<br>sudo systemctl start mariadb<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u82f1\u6587\u539f\u6587\u53c2\u8003\u5730\u5740 1\u3001\u68c0\u67e5\u7248\u672cmysql &#8211;versionMySQL output mysql V &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/thereisno.top\/?p=261\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cmysql\u91cd\u7f6eroot\u5bc6\u7801\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[68,67],"class_list":["post-261","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql","tag-67"],"_links":{"self":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=261"}],"version-history":[{"count":1,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":262,"href":"https:\/\/thereisno.top\/index.php?rest_route=\/wp\/v2\/posts\/261\/revisions\/262"}],"wp:attachment":[{"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thereisno.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}