Thursday, July 15, 2010

HOWTO reset mysql database root password

Despite having a pretty decent password storage system, I occasionally find myself without a root password for my MySQL dev servers.  MySQL has a procedure for resetting the password that involves using an init file.  Personally I like this (similar) solution better because you don't need to worry about syntax errors in your SQL since you have an interactive prompt.  Here is the summary:

/etc/init.d/mysql stop
mysqld_safe --skip-grant-tables &
mysql -u root mysql
UPDATE user SET password=PASSWORD("ualue=42") WHERE user="root";
/etc/init.d/mysql restart

No comments: