{"id":1592,"date":"2015-01-14T05:43:27","date_gmt":"2015-01-14T05:43:27","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=1592"},"modified":"2015-01-14T05:43:27","modified_gmt":"2015-01-14T05:43:27","slug":"reset-mysql-password","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/01\/14\/reset-mysql-password\/","title":{"rendered":"Reset the Mysql password"},"content":{"rendered":"<p>How to reset the mysql password on a linux server.<\/p>\n<h5>CentOS<\/p>\n<p>First, stop the MySQL service\/daemon. On Centos\/RHEL you would run:<\/h5>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># service mysqld stop\n\n<\/pre>\n<p>Next, edit the MySQL config file (\/etc\/my.cnf on CentOS\/RHEL) and add the following to the [mysqld] section.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# skip-grant-tables\n<\/pre>\n<p>Start MySQL back up<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# service mysqld start \n\n<\/pre>\n<p>You will now be able to connect as user root without any password.<\/p>\n<p>Run the following SQL queries:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmysql&amp;gt; UPDATE mysql.user SET Password=PASSWORD(&#039;MyNewPass&#039;) WHERE User=&#039;root&#039;; \nFLUSH PRIVILEGES;\n\n<\/pre>\n<p>Remove the skip-grant-tables line from the MYSQL config file, and restart MySQL one final time.<\/p>\n<h5>Ubuntu 16<\/h5>\n<p>First off stop mySQL<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo service mysql stop\n\n<\/pre>\n<p>Now manually create the socket directory for MySQLD to be able to start up and give mysql permissions to it. (THIS is the most important step that all guides fail to mention leading people into doing very stupid thing when they cannot get mysqld to start)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo mkdir \/var\/run\/mysqld; sudo chown mysql \/var\/run\/mysqld\n\n<\/pre>\n<p>Now start mysql with the \u2013skip-grant-tables option because you are not checking user privs at this point<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo mysqld_safe --skip-grant-tables &amp;amp;\n\n<\/pre>\n<p>Now log into mysql as root<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo mysql -u root\n\n<\/pre>\n<p>Now run the following commands in the mysql console<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nmysql&amp;gt; use mysql;\nmysql&amp;gt; FLUSH PRIVILEGES;\nmysql&amp;gt; SET PASSWORD FOR root@&#039;localhost&#039; = PASSWORD(&#039;yournewpassword&#039;);\nmysql&amp;gt; FLUSH PRIVILEGES;\nmysql&amp;gt; exit\n\n<\/pre>\n<p>Now stop mySQL and Restart it<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo service mysql stop\n# sudo service mysql start\n\n<\/pre>\n<p>or<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo \/etc\/init.d\/mysql stop\n# sudo \/etc\/init.d\/mysql start\n\n<\/pre>\n<p>Check if mySQL started properly by running<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo service mysql status\n\n<\/pre>\n<p>Now to make sure everything is OK reboot your server and after reboot run<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# sudo service mysql status\n\n<\/pre>\n<p>Now you can test logging into mySQL with your new password by running<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# mysql -u root -p\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to reset the mysql password on a linux server. CentOS First, stop the MySQL service\/daemon. On Centos\/RHEL you would run: # service mysqld stop Next, edit the MySQL config file (\/etc\/my.cnf on CentOS\/RHEL) and add the following to the [mysqld] section. # skip-grant-tables Start MySQL back up # service mysqld start You will now &#8230; <a title=\"Reset the Mysql password\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/01\/14\/reset-mysql-password\/\" aria-label=\"Read more about Reset the Mysql password\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70,117],"tags":[],"class_list":["post-1592","post","type-post","status-publish","format-standard","hentry","category-mysql","category-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/1592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=1592"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/1592\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=1592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=1592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=1592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}