{"id":561,"date":"2010-03-14T06:43:28","date_gmt":"2010-03-14T10:43:28","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=561"},"modified":"2014-01-18T07:16:34","modified_gmt":"2014-01-18T11:16:34","slug":"mysql-access-denied-for-user-rootlocalhost","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/mysql-access-denied-for-user-rootlocalhost","title":{"rendered":"Mysql: Access denied for user &#8216;root&#8217;@&#8217;localhost&#8217;"},"content":{"rendered":"<p>You may receive the <strong>&#8220;Access denied for user &#8216;root&#8217;@&#8217;localhost'&#8221;<\/strong> message while accessing mysql from the command prompt.<\/p>\n<p>The error message states that the Mysql password for user &#8216;root&#8217; is incorrect and need to <strong>reset the password using the skip-grant-tables method.<\/strong><\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">ERROR 1045 (28000): Access denied for user 'root'@'localhost' <\/span>\r\n<span style=\"color: #0000ff;\">(using password: NO)<\/span><\/pre>\n<\/blockquote>\n<p><strong>How to reset root Mysql password in Linux?<\/strong><\/p>\n<p>First stop the mysql service<strong><br \/>\n<\/strong><\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># \/etc\/init.d\/mysql stop<\/span><\/pre>\n<\/blockquote>\n<p>Make sure all the mysql processes are stopped by executing the killall command<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># killall -9 mysqld<\/span><\/pre>\n<\/blockquote>\n<p>Next, start mysql is safe mode i.e. the privileges will be skipped while connecting to the mysql server<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># \/usr\/bin\/mysqld_safe --skip-grant-tables &amp;<\/span><\/pre>\n<\/blockquote>\n<p>now, connect to your Mysql prompt using the &#8216;mysql&#8217; command<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># mysql<\/span>\r\n <span style=\"color: #0000ff;\">Welcome to the MySQL monitor. Commands end with ; or \\g.<\/span>\r\n <span style=\"color: #0000ff;\">Your MySQL connection id is 23056<\/span>\r\n <span style=\"color: #0000ff;\">mysql&gt;<\/span><\/pre>\n<\/blockquote>\n<p>Goto the &#8216;mysql&#8217; database<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">mysql&gt; use mysql;<\/span><\/pre>\n<\/blockquote>\n<p>Now set a password for user &#8216;root&#8217;<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">mysql&gt; update user set password=PASSWORD(\"passhere\") where user='root';<\/span><\/pre>\n<\/blockquote>\n<p>OR you can also set a blank password for user &#8216;root&#8217;<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">mysql&gt; update user set password=PASSWORD(\"\") where user='root';<\/span><\/pre>\n<\/blockquote>\n<p>Once done, reload privileges and quit<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\">mysql&gt; flush privileges;<\/span>\r\n<span style=\"color: #0000ff;\">mysql&gt; quit<\/span><\/pre>\n<\/blockquote>\n<p>Now, restart the mysql service<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># \/etc\/init.d\/mysql restart<\/span><\/pre>\n<\/blockquote>\n<p>and you should be able to connect to your mysql server:<\/p>\n<blockquote>\n<pre><span style=\"color: #0000ff;\"># mysql<\/span>\r\nOR\r\n<span style=\"color: #0000ff;\"># mysql -uroot -p<\/span><\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>You may receive the &#8220;Access denied for user &#8216;root&#8217;@&#8217;localhost&#8217;&#8221; message while accessing mysql from the command prompt.<br \/>\nThe error message states that the Mysql password for user &#8216;root&#8217; is incorrect and need to reset the password using the skip-grant-tables method.<\/p>\n<p>ERROR 1045 (28000): Access denied for user &#8216;root&#8217;@&#8217;localhost&#8217;<br \/>\n(using password: NO)<\/p>\n<p>How to reset root Mysql password in Linux?<br \/>\nFirst stop the mysql service<\/p>\n<p># \/etc\/init.d\/mysql stop<\/p>\n<p>Make sure all the mysql processes are stopped by executing the killall command<\/p>\n<p># killall -9 mysqld<\/p>\n<p>Next, start mysql is safe mode i.e. the privileges will be skipped [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[111],"tags":[742,744,745,1487,746],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/561"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=561"}],"version-history":[{"count":10,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/561\/revisions"}],"predecessor-version":[{"id":2177,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/561\/revisions\/2177"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}