{"id":41,"date":"2008-09-22T11:02:47","date_gmt":"2008-09-22T16:02:47","guid":{"rendered":"http:\/\/www.popmartian.com\/tipsntricks\/?p=41"},"modified":"2008-10-03T11:31:20","modified_gmt":"2008-10-03T16:31:20","slug":"change-or-recover-mysql-root-password","status":"publish","type":"post","link":"https:\/\/www.popmartian.com\/tipsntricks\/2008\/09\/22\/change-or-recover-mysql-root-password\/","title":{"rendered":"Change or recover MySQL root password"},"content":{"rendered":"<p><strong>To Change a Known Password<\/strong><br \/>\nIf you know the current password, use one of these methods to reset it.\u00c2\u00a0 If you do not know, skip ahead to the next section.<\/p>\n<p><strong>Using mysqladmin if there is no password:<\/strong><\/p>\n<p><code>$ mysqladmin -u root password &lt;new password&gt;<\/code><\/p>\n<p><strong>Using mysqladmin if there is a password:<\/strong><br \/>\n<code>$ mysqladmin -u root -p &lt;old password&gt; &lt;new password&gt;<\/code><\/p>\n<p><strong>Using mysql shell if there is no password<\/strong><br \/>\n<code>mysql -u root<br \/>\nmysql&gt; update user set password=PASSWORD(\"&lt;new password&gt;\") where User='root';<br \/>\nmysql&gt; flush privileges;<br \/>\nmysql&gt; quit<\/code><\/p>\n<p><strong>Using mysql shell if there is a password<\/strong><br \/>\n<code>mysql -u root -p<br \/>\nPassword: &lt;old password&gt;<br \/>\nmysql&gt; update user set password=PASSWORD(\"&lt;new password&gt;\") where User='root';<br \/>\nmysql&gt; flush privileges;<br \/>\nmysql&gt; quit<\/code><\/p>\n<p><strong>Recover\/reset the password if you don&#8217;t know it<\/strong><br \/>\nThere is no way to recover the password if you don&#8217;t know it, but you can reset it to something new.<br \/>\nYou must have root on the box for this.<\/p>\n<ol>\n<li>Kill the running server<\/li>\n<li>Create a text file with the following contents:<br \/>\n<code>UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';<br \/>\nFLUSH PRIVILEGES;<\/code><\/li>\n<li>Run the mysql_safe binary with the <code>--init-file<\/code> option pointing to your new file like this:<br \/>\n<code>mysqld_safe --init-file=\/path\/to\/file &amp;<\/code><\/li>\n<li>Delete the init file you created.<\/li>\n<li>Stop and start MySQL normally.<\/li>\n<\/ol>\n<blockquote><p>Did you find this post useful or have questions or comments?\u00c2\u00a0 Please let me know!<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>To Change a Known Password If you know the current password, use one of these methods to reset it.\u00c2\u00a0 If you do not know, skip ahead to the next section. Using mysqladmin if there is no password: $ mysqladmin -u &hellip; <a href=\"https:\/\/www.popmartian.com\/tipsntricks\/2008\/09\/22\/change-or-recover-mysql-root-password\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/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":[3,53],"tags":[48,74],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-how-to-do-stuff","category-mysql","tag-howto","tag-mysql"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":5,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":43,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/posts\/41\/revisions\/43"}],"wp:attachment":[{"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.popmartian.com\/tipsntricks\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}