{"id":155,"date":"2016-11-01T10:40:58","date_gmt":"2016-11-01T10:40:58","guid":{"rendered":"http:\/\/siteblog.tuc.gr\/emmanuel\/?p=155"},"modified":"2016-11-02T09:47:45","modified_gmt":"2016-11-02T09:47:45","slug":"reset-mysql-root-password","status":"publish","type":"post","link":"https:\/\/siteblog.tuc.gr\/emmanuel\/reset-mysql-root-password\/","title":{"rendered":"Reset MySQL root password"},"content":{"rendered":"<p><strong>How can I reset my MySQL password?<\/strong><br \/>\nFollowing this procedure, you will disable access control on the MySQL server. All connexions will have a root access. It is a good thing to unplug your server from the network or at least disable remote access.<\/p>\n<p>To reset your mysqld password just follow these instructions :<\/p>\n<ol>\n<li>Stop the mysql demon process using this command :<br \/>\n<span style=\"color: #008000\">sudo \/etc\/init.d\/mysql stop<\/span><\/li>\n<li>\u00a0Start the mysqld demon process using the &#8211;skip-grant-tables option with this command<br \/>\n<span style=\"color: #008000\">sudo \/usr\/sbin\/mysqld &#8211;skip-grant-tables &#8211;skip-networking &amp;<\/span><\/li>\n<\/ol>\n<p>Because you are not checking user privs at this point, it&#8217;s safest to disable networking. In Dapper, \/usr\/bin\/mysqld&#8230; did not work. However, mysqld &#8211;skip-grant-tables did.<\/p>\n<ol>\n<li>start the mysql client process using this command<br \/>\n<span style=\"color: #008000\">mysql -u root<\/span><\/li>\n<li>from the mysql prompt execute this command to be able to change any password<br \/>\n<span style=\"color: #008000\">FLUSH PRIVILEGES;<\/span><\/li>\n<li>Then reset\/update your password<br \/>\n<span style=\"color: #008000\">SET PASSWORD FOR root@&#8217;localhost&#8217; = PASSWORD(&#8216;password&#8217;);<\/span><\/li>\n<li>If you have a mysql root account that can connect from everywhere, you should also do:<br \/>\n<span style=\"color: #008000\">UPDATE mysql.user SET Password=PASSWORD(&#8216;newpwd&#8217;) WHERE User=&#8217;root&#8217;;<\/span><\/li>\n<li>Alternate Method:<br \/>\n<span style=\"color: #008000\">USE mysql<\/span><br \/>\n<span style=\"color: #008000\"> UPDATE user SET Password = PASSWORD(&#8216;newpwd&#8217;)<\/span><br \/>\n<span style=\"color: #008000\"> WHERE Host = &#8216;localhost&#8217; AND User = &#8216;root&#8217;;<\/span><\/li>\n<li>And if you have a root account that can access from everywhere:<br \/>\n<span style=\"color: #008000\">USE mysql<\/span><br \/>\n<span style=\"color: #008000\"> UPDATE user SET Password = PASSWORD(&#8216;newpwd&#8217;)<\/span><br \/>\n<span style=\"color: #008000\"> WHERE Host = &#8216;%&#8217; AND User = &#8216;root&#8217;;<\/span><\/li>\n<\/ol>\n<p>For either method, once have received a message indicating a successful query (one or more rows affected), flush privileges:<\/p>\n<p><span style=\"color: #008000\">FLUSH PRIVILEGES;<\/span><br \/>\nThen stop the mysqld process and relaunch it with the classical way:<\/p>\n<p><span style=\"color: #008000\">sudo \/etc\/init.d\/mysql stop<\/span><br \/>\n<span style=\"color: #008000\"> sudo \/etc\/init.d\/mysql start<\/span><br \/>\nWhen you have completed all this steps ,you can easily access to your mysql server with the password you have set in the step before. An easy way to have a full control of your mysql server is phpmyadmin (www.phpmyadmin.net), software made in php that can give you a web interface that can be very usefull to people that havent got a lot of confidence with bash .To install phpmyadmin on you server you will need to have 4 things:<\/p>\n<ol>\n<li>web server apache<\/li>\n<li>php<\/li>\n<li>mysql server\/mysql client installed<\/li>\n<li>php_mysql support for apache<\/li>\n<\/ol>\n<p>All packages can be found browsing synaptic.<\/p>\n<hr \/>\n<p><strong>Another way, purge<\/strong><br \/>\nI also had some problems with mysql just not accepting my password. I tried the other way as well and it just ended up being difficult. I had not been able to use mysql so it was empty anyway. If this is also your case you may opt for the PURGE way. This removes every file related to mysql. Depending on your installation the packages might be diffrent, mysql-server in 6.10 is called mysql-server-5.0 as an example.<\/p>\n<p>USE THIS AS A LAST RESORT METHOD, YOU WILL LOSE ALL YOUR MYSQL DATA<\/p>\n<p><span style=\"color: #008000\">sudo apt-get &#8211;purge remove mysql-server mysql-common mysql-client<\/span><\/p>\n<p><span style=\"color: #008000\">sudo apt-get install mysql-server mysql-common mysql-client<\/span><br \/>\nIn the next step be sure to chance the your-new-password with the password you want!<\/p>\n<p><span style=\"color: #008000\">mysqladmin -u root password your-new-password<\/span><br \/>\n<span style=\"color: #008000\"> sudo \/etc\/init.d\/mysql restart<\/span><\/p>\n<p><span style=\"color: #008000\">mysql -u root -p<\/span><br \/>\nYou should now be logged in as root. Make sure to notedown your password! Thanks to Illuvator for posting this method in the ubuntu forum.<\/p>\n<p>The Easiest Method<\/p>\n<p><span style=\"color: #008000\">sudo dpkg-reconfigure mysql-server-N.N<\/span><\/p>\n<hr \/>\n<p><a href=\"https:\/\/help.ubuntu.com\/community\/MysqlPasswordReset\">https:\/\/help.ubuntu.com\/community\/MysqlPasswordReset<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How can I reset my MySQL password? Following this procedure, you will disable access control on the MySQL server. All connexions will have a root access. It is a good thing to unplug your server from the network or at least disable remote access. To reset your mysqld password just follow these instructions : Stop [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-155","post","type-post","status-publish","format-standard","hentry","category-php-mysql-apache"],"_links":{"self":[{"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/posts\/155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/comments?post=155"}],"version-history":[{"count":3,"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/posts\/155\/revisions"}],"predecessor-version":[{"id":159,"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/posts\/155\/revisions\/159"}],"wp:attachment":[{"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/media?parent=155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/categories?post=155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/siteblog.tuc.gr\/emmanuel\/wp-json\/wp\/v2\/tags?post=155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}