{"id":322,"date":"2011-05-12T20:23:49","date_gmt":"2011-05-12T17:23:49","guid":{"rendered":"http:\/\/oss-it.su\/?p=322"},"modified":"2019-08-11T14:44:41","modified_gmt":"2019-08-11T11:44:41","slug":"%d0%b2%d0%be%d1%81%d1%81%d1%82%d0%b0%d0%bd%d0%be%d0%b2%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-%d0%bf%d0%b0%d1%80%d0%be%d0%bb%d1%8f-root-%d0%b2-mysql","status":"publish","type":"post","link":"https:\/\/oss-it.su\/en\/322","title":{"rendered":"MySQL \u00ad Restoring the root password"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright wp-image-711 size-full img-responsive\" src=\"https:\/\/oss-it.su\/wp-content\/uploads\/2011\/05\/Logo-mysql.jpg\" alt=\"logo-mysql\" width=\"399\" height=\"291\" srcset=\"https:\/\/oss-it.su\/wp-content\/uploads\/2011\/05\/Logo-mysql.jpg 399w, https:\/\/oss-it.su\/wp-content\/uploads\/2011\/05\/Logo-mysql-300x219.jpg 300w\" sizes=\"auto, (max-width: 399px) 100vw, 399px\" \/>A common problem with mysql databases is the loss of the root password for various reasons. This article will describe how to quickly recover a root password in mysql without losing data, using Debian\/Ubuntu as an example.<\/p>\n<p>Usually, when trying to run <code>mysql<\/code>, this problem is followed by a message:<\/p>\n<p><code>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)<\/code><\/p>\n<p>or<\/p>\n<p><code>ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)<\/code><\/p>\n<p>To change the root password in <em>mysql<\/em>, log in to the root session in the console first:<\/p>\n<p><code>su<\/code><\/p>\n<p>Then stop the running <em>mysql<\/em> service running:<\/p>\n<p><code>service mysql stop<\/code><\/p>\n<p>After using this command:<\/p>\n<p><code>mysqld_safe --skip-grant-tables &amp;<\/code><\/p>\n<p>you can login to <em>mysql<\/em> without a password:<\/p>\n<p><code>mysql -uroot mysql<\/code><\/p>\n<p>In the <em>mysql<\/em> session, enter the following lines:<\/p>\n<p><code>UPDATE user SET password=PASSWORD(\"your_password\") WHERE user=\"root\";<br \/>\nFLUSH PRIVILEGES;<br \/>\nEXIT<\/code><\/p>\n<p>Where instead of <em>your_password<\/em> &#8211; enter your new password.<\/p>\n<p>After that you only need to run <em>mysql<\/em>:<\/p>\n<p><code>\/etc\/init.d\/mysql restart<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A common problem with mysql databases is the loss of the root password for various reasons. This article will describe how to quickly recover a root password in mysql without losing data, using Debian\/Ubuntu as an example.<\/p>\n","protected":false},"author":1,"featured_media":712,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[8],"class_list":["post-322","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-system","tag-mysql"],"_links":{"self":[{"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/posts\/322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/comments?post=322"}],"version-history":[{"count":1,"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/posts\/322\/revisions"}],"predecessor-version":[{"id":713,"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/posts\/322\/revisions\/713"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/media\/712"}],"wp:attachment":[{"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/media?parent=322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/categories?post=322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oss-it.su\/en\/wp-json\/wp\/v2\/tags?post=322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}