{"id":1838,"date":"2013-01-24T17:40:32","date_gmt":"2013-01-24T09:40:32","guid":{"rendered":"http:\/\/rmohan.com\/?p=1838"},"modified":"2013-01-24T17:40:32","modified_gmt":"2013-01-24T09:40:32","slug":"resetting-mysql-root-password-red-hat-and-centos","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1838","title":{"rendered":"Resetting MySQL Root Password: Red Hat and CentOS"},"content":{"rendered":"<p>If you&#8217;ve forgotten your MySQL root password (or are involved with some nefarious activity), here is how you can reset that password on a Red Hat (RHEL) system or a CentOS system:<\/p>\n<p> Stop MySQL:<\/p>\n<blockquote><p>root# \u00a0service mysqld stop<\/p><\/blockquote>\n<p> Start MySQL in safe mode:<\/p>\n<blockquote><p>root# \u00a0mysqld_safe &#8211;skip-grant-tables &amp;<\/p><\/blockquote>\n<p> Log into MySQL as root:<\/p>\n<blockquote><p>root# \u00a0mysql -u root<\/p><\/blockquote>\n<p> Reset the password:<\/p>\n<blockquote><p>mysql&gt; \u00a0update mysql.user set password=PASSWORD(&#8220;YourNewPassW0RD&#8221;) where User=&#8217;root&#8217;;<\/p><\/blockquote>\n<blockquote><p>mysql&gt; \u00a0flush privileges; exit;<\/p><\/blockquote>\n<p> Log out of MySQL and stop the Safe Mode:<\/p>\n<blockquote><p>root# \u00a0service mysqld stop<\/p><\/blockquote>\n<p> Start MySQL in the normal mode:<\/p>\n<blockquote><p>root# \u00a0service mysqld start<\/p><\/blockquote>\n<p> Log into MySQL with your new password:<\/p>\n<blockquote><p>root# \u00a0mysql -u root -p<\/p><\/blockquote>\n<blockquote><p>Enter password:<\/p><\/blockquote>\n<blockquote><p>mysql&gt;<\/p><\/blockquote>\n<blockquote>\n<h3>Resetting MySQL Root Password: Debian or Ubuntu<\/h3>\n<div>\u00a0<\/div>\n<p>If you&#8217;ve forgotten your MySQL root password (or are involved with some nefarious activity), here is how you can reset that password on a Debian GNU\/Linux system or an Ubuntu GNU\/Linux system:<\/p>\n<p> Find out the account that the system uses to start and stop MySQL (note that I&#8217;ve changed the password for this demo):<\/p>\n<blockquote><p>root# \u00a0cat\u00a0\/etc\/mysql\/debian.cnf<\/p><\/blockquote>\n<p> # Automatically generated for Debian scripts. DO NOT TOUCH!<br \/> [client]<br \/> host \u00a0 \u00a0 = localhost<br \/> user \u00a0 \u00a0 = debian-sys-maint<br \/> password = 11223344554433<br \/> socket \u00a0 = \/var\/run\/mysqld\/mysqld.sock<br \/> [mysql_upgrade]<br \/> user \u00a0 \u00a0 = debian-sys-maint<br \/> password = 11223344554433<br \/> socket \u00a0 = \/var\/run\/mysqld\/mysqld.sock<br \/> basedir \u00a0= \/usr<\/p>\n<p> Log into MySQL with that account:<\/p>\n<blockquote><p>root# \u00a0mysql -u debian-sys-maint\u00a0-p<\/p><\/blockquote>\n<blockquote><p>Enter password:<\/p><\/blockquote>\n<blockquote><p>mysql&gt;<\/p><\/blockquote>\n<p> Change the password:<\/p>\n<blockquote><p>mysql&gt; \u00a0update mysql.user set password=PASSWORD(&#8220;YourNewPassW0RD&#8221;) where User=&#8217;root&#8217;;<\/p><\/blockquote>\n<blockquote><p>mysql&gt; \u00a0flush privileges; exit;<\/p><\/blockquote>\n<p> Log into MySQL as root with your new password:<\/p>\n<blockquote><p>root# \u00a0mysql -u root -p<\/p><\/blockquote>\n<blockquote><p>Enter password:<\/p><\/blockquote>\n<blockquote><p>mysql&gt;<\/p><\/blockquote>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve forgotten your MySQL root password (or are involved with some nefarious activity), here is how you can reset that password on a Red Hat (RHEL) system or a CentOS system:<\/p>\n<p> Stop MySQL:<\/p>\n<p>root# service mysqld stop<\/p>\n<p> Start MySQL in safe mode:<\/p>\n<p>root# mysqld_safe &#8211;skip-grant-tables &amp;<\/p>\n<p> Log into MySQL as root:<\/p>\n<p> [&#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\/1838"}],"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=1838"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1838\/revisions"}],"predecessor-version":[{"id":1841,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1838\/revisions\/1841"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}