{"id":2267,"date":"2013-07-12T15:26:47","date_gmt":"2013-07-12T07:26:47","guid":{"rendered":"http:\/\/rmohan.com\/?p=2267"},"modified":"2013-07-12T15:27:58","modified_gmt":"2013-07-12T07:27:58","slug":"how-to-recover-a-mysql-root-password","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=2267","title":{"rendered":"How to Recover a Mysql Root Password"},"content":{"rendered":"<div>Let&#8217;s\u00a0 check how can we recover mysql root password if we lost it<\/div>\n<div><\/div>\n<div>Step # 1: Stop the MySQL server process.<\/div>\n<div>Step # 2: Start the MySQL (mysqld) server\/daemon process with the &#8211;skip-grant-tables option so that it will not prompt for password.<\/div>\n<div>Step # 3: Connect to mysql server as the root user.<\/div>\n<div>Step # 4: Setup new mysql root account password.<\/div>\n<div>Step # 5: Exit and restart the MySQL server.<\/div>\n<div><\/div>\n<div>Here are commands you need to type for each step (login as the root user)<\/div>\n<p>&nbsp;<\/p>\n<div># service mysqld stop<\/div>\n<div># mysqld_safe &#8211;skip-grant-tables &amp;<\/div>\n<p>[1] 13964<br \/>\nroot@localhost ~]# Starting mysqld daemon with databases from \/var\/lib\/mysql\u00a0 &#8212;&#8212;&#8212;&#8212;nothing will show just type mysql<br \/>\n<b>mysql<\/b>\u00a0&#8212;&#8211; typing mysql shows like this<br \/>\nWelcome to the MySQL monitor. Commands end with ; or g.<br \/>\nYour MySQL connection id is 1<br \/>\nServer version: 5.0.77 Source distribution<br \/>\nType &#8216;help;&#8217; or &#8216;h&#8217; for help. Type &#8216;c&#8217; to clear the buffer.<br \/>\nOr<br \/>\nctrl z then<\/p>\n<div>#mysql<\/div>\n<div>mysql&gt; use mysql;<\/div>\n<div>mysql&gt;update user set password=PASSWORD(&#8220;password@123#&#8221;) WHERE user=&#8221;root&#8221;;<\/div>\n<div>mysql&gt; flush privileges;<\/div>\n<div>mysql&gt; quit<\/div>\n<div># \/etc\/init.d\/mysql stop<\/div>\n<div># \/etc\/init.d\/mysql start<\/div>\n<div><\/div>\n<p># mysql -u root -p\u00a0 &#8212;&#8212; enter the database with new password<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s check how can we recover mysql root password if we lost it Step # 1: Stop the MySQL server process. Step # 2: Start the MySQL (mysqld) server\/daemon process with the &#8211;skip-grant-tables option so that it will not prompt for password. Step # 3: Connect to mysql server as the root user. Step # [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2267"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2267"}],"version-history":[{"count":3,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2267\/revisions"}],"predecessor-version":[{"id":2269,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/2267\/revisions\/2269"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}