{"id":200,"date":"2010-05-07T10:17:55","date_gmt":"2010-05-07T18:17:55","guid":{"rendered":"http:\/\/hongyu.org\/wordpress\/?p=200"},"modified":"2010-05-21T14:17:00","modified_gmt":"2010-05-21T22:17:00","slug":"reset-mysql-root-password-under-windows-or-nix","status":"publish","type":"post","link":"https:\/\/www.hongyu.org\/wordpress\/?p=200","title":{"rendered":"Reset mysql root password under Windows or *nix"},"content":{"rendered":"<h3>Windows (mainly copied from <a href=\"http:\/\/www.geekpedia.com\/KB105_How-to-reset-your-MySQL-root-password-under-Windows.html\">Geekpedia<\/a>)<\/h3>\n<p>1. Stop your MySQL server completely. This can be done by accessing the Services window inside Windows XP and Windows Server 2003, where you can stop the MySQL service. <\/p>\n<p>2. Open your MS-DOS command prompt using &#8220;cmd&#8221; inside the Run window. Inside it navigate to your MySQL bin folder, such as C:\\MySQL\\bin using the cd command. <\/p>\n<p>3. Execute the following command in the command prompt: mysqld.exe -u root &ndash;&ndash;skip-grant-tables <\/p>\n<p>4. Leave the current MS-DOS command prompt as it is, and open a new MS-DOS command prompt window. <\/p>\n<p>5. Navigate to your MySQL bin folder, such as C:\\MySQL\\bin using the cd command. <\/p>\n<p>6. Enter &#8220;mysql&#8221; and press enter. <\/p>\n<p>7. You should now have the MySQL command prompt working. Type &#8220;use mysql;&#8221; so that we switch to the &#8220;mysql&#8221; database. <\/p>\n<p>8. Execute the following command to update the password: <\/p>\n<p>UPDATE user SET Password = PASSWORD(&#8216;NEW_PASSWORD&#8217;) WHERE User = &#8216;root&#8217;; <\/p>\n<p>However, you can now run any SQL command that you wish. <\/p>\n<p>After you are finished close the first command prompt and type &#8220;exit;&#8221; in the second command prompt windows to disconnect successfully. You can now start the MySQL service. <\/p>\n<p>Please note that the 8 step process above can differ depending on the MySQL version you are using, how you configured your server, etc. However, many times you can still easily work around a problem that you experience in any of the steps.<\/p>\n<h3>Linux\/Unix (mainly copied from <a href=\"http:\/\/www.cyberciti.biz\/tips\/recover-mysql-root-password.html\">ciberciti<\/a>)<\/h3>\n<p>Step # 1 : Stop mysql service<\/p>\n<p># \/etc\/init.d\/mysql stop<\/p>\n<p>Output:<\/p>\n<p>Stopping MySQL database server: mysqld.<br \/>\nStep # 2: Start to MySQL server w\/o password:<\/p>\n<p># mysqld_safe &ndash;&ndash;skip-grant-tables &#038;<\/p>\n<p>Output:<\/p>\n<p>[1] 5988<br \/>\nStarting mysqld daemon with databases from \/var\/lib\/mysql<br \/>\nmysqld_safe[6025]: started<br \/>\nStep # 3: Connect to mysql server using mysql client:<\/p>\n<p># mysql -u root<\/p>\n<p>Output:<\/p>\n<p>Welcome to the MySQL monitor.  Commands end with ; or \\g.<br \/>\nYour MySQL connection id is 1 to server version: 4.1.15-Debian_1-log<\/p>\n<p>Type &#8216;help;&#8217; or &#8216;\\h&#8217; for help. Type &#8216;\\c&#8217; to clear the buffer.<\/p>\n<p>mysql><br \/>\nStep # 4: Setup new MySQL root user password<\/p>\n<p>mysql> use mysql;<br \/>\nmysql> update user set password=PASSWORD(&#8220;NEW-ROOT-PASSWORD&#8221;) where User=&#8217;root&#8217;;<br \/>\nmysql> flush privileges;<br \/>\nmysql> quit<\/p>\n<p>Step # 5: Stop MySQL Server:<\/p>\n<p># \/etc\/init.d\/mysql stop<\/p>\n<p>Output:<\/p>\n<p>Stopping MySQL database server: mysqld<br \/>\nSTOPPING server from pid file \/var\/run\/mysqld\/mysqld.pid<br \/>\nmysqld_safe[6186]: ended<\/p>\n<p>[1]+  Done                    mysqld_safe &#8211;skip-grant-tables<br \/>\nStep # 6: Start MySQL server and test it<\/p>\n<p># \/etc\/init.d\/mysql start<br \/>\n# mysql -u root -p<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows (mainly copied from Geekpedia) 1. Stop your MySQL server completely. This can be done by accessing the Services window inside Windows XP and Windows Server 2003, where you can stop the MySQL service. 2. Open your MS-DOS command prompt using &#8220;cmd&#8221; inside the Run window. Inside it navigate to your MySQL bin folder, such &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.hongyu.org\/wordpress\/?p=200\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Reset mysql root password under Windows or *nix&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/200"}],"collection":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=200"}],"version-history":[{"count":8,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/200\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hongyu.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}