{"id":1053,"date":"2009-02-05T22:50:43","date_gmt":"2009-02-06T02:50:43","guid":{"rendered":"http:\/\/blogs.sungeek.net\/unixwiz\/?p=1053"},"modified":"2009-02-19T22:49:22","modified_gmt":"2009-02-20T02:49:22","slug":"mysql-root-password-recovery","status":"publish","type":"post","link":"https:\/\/blogs.sungeek.net\/unixwiz\/2009\/02\/05\/mysql-root-password-recovery\/","title":{"rendered":"MySQL root password recovery"},"content":{"rendered":"<p>Quick steps to recovering (aka resetting) the root password on MySQL:<\/p>\n<p>1. Find the PID of the mysql process<br \/>\n<code lang=\"bash\">ps -aef | grep mysqld<br \/>\nroot 11889 11090   0   Jun 10 ?           0:00 \/bin\/sh bin\/safe_mysqld<br \/>\nmysql 11909 11889   0   Jun 10 ?         525:44 \/local\/mysql-5.0.45-solaris10-i386\/bin\/mysqld --basedir=\/local\/mysql-5.0.45-sol<\/p>\n<p><\/code><br \/>\n2. Kill the mysql process; <code lang=\"bash\">kill 11909<\/code> Make sure not to use a -9&#8230;<br \/>\n3. Create a file that the user that runs mysql can access; and place in it the following:<br \/>\n<code lang=\"sql\"><br \/>\nUPDATE mysql.user SET Password=PASSWORD('FozzyBear') WHERE User='root';<br \/>\nFLUSH PRIVILEGES;<br \/>\n<\/code><\/p>\n<p>4. Start mysql: <code lang=\"bash\">mysqld_safe --init-file=\/path\/to\/file &<\/code><br \/>\n5. Try to connect as root now, if it works, delete the temp file; stop and restart mysql.<\/p>\n<p>Granted, the above can be done by any one who knows the password for the account that MySQL runs under, or has root access to the machine. I usually leave the mysql UNIX account in a locked state, so no one can su to it, so you have to have access to root, to be able to su to it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Quick steps to recovering (aka resetting) the root password on MySQL: 1. Find the PID of the mysql process ps -aef | grep mysqld root 11889 11090 0 Jun 10 ? 0:00 \/bin\/sh bin\/safe_mysqld mysql 11909 11889 0 Jun 10 ? 525:44 \/local\/mysql-5.0.45-solaris10-i386\/bin\/mysqld &#8211;basedir=\/local\/mysql-5.0.45-sol 2. Kill the mysql process; kill 11909 Make sure not to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blogs.sungeek.net\/unixwiz\/2009\/02\/05\/mysql-root-password-recovery\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MySQL root password recovery&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61,42],"tags":[502,101,484,486],"class_list":["post-1053","post","type-post","status-publish","format-standard","hentry","category-mysql","category-random-stuff","tag-mysql","tag-password-recovery","tag-random-stuff","tag-security"],"_links":{"self":[{"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/posts\/1053","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/comments?post=1053"}],"version-history":[{"count":2,"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/posts\/1053\/revisions"}],"predecessor-version":[{"id":1067,"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/posts\/1053\/revisions\/1067"}],"wp:attachment":[{"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/media?parent=1053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/categories?post=1053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.sungeek.net\/unixwiz\/wp-json\/wp\/v2\/tags?post=1053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}