Difference between revisions of "Reset MySQL root password"

From Organic Design wiki
(Created page with '{{procedure |status = In use |role = sysop }} To reset the root password of a MySQL server, first go to a root shell and stop MySQL: {{code|<pre> /etc/init.d/mysql stop </pre>}} ...')
 
(better process)
Line 11: Line 11:
 
Next, run MySQL in safe mode in the background:
 
Next, run MySQL in safe mode in the background:
 
{{code|<pre>
 
{{code|<pre>
/usr/local/mysql/bin/safe_mysqld --user=mysql --skip-grant-tables --skip-networking &
+
mysqld_safe --skip-grant-tables &
 
</pre>}}
 
</pre>}}
  
Line 17: Line 17:
 
Reset the MySQL root password:
 
Reset the MySQL root password:
 
{{code|<pre>
 
{{code|<pre>
/usr/local/mysql/bin/mysqladmin -u root flush-privileges password "******"
+
mysql -u root
 +
use mysql;
 +
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
 +
flush privileges;
 +
quit
 
</pre>}}
 
</pre>}}
  

Revision as of 16:43, 20 May 2013

Procedure.svg Reset MySQL root password
Organic Design procedure

To reset the root password of a MySQL server, first go to a root shell and stop MySQL:

/etc/init.d/mysql stop


Next, run MySQL in safe mode in the background:

mysqld_safe --skip-grant-tables &


Reset the MySQL root password:

mysql -u root
use mysql;
update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit


And restart the MySQL server again:

/etc/init.d/mysql restart