donmcarthur.com

posted: Sat 16 Jan 2010 8:27 am

You'd be surprised at how often the problem of resetting the mysql root user account comes up in the freenode #mysql irc channel. People are always referred to the online manual directions, but most can't successfully follow them. I wrote up this quick and dirty summary. This assumes you are at a local shell and that having the database exposed temporarily without account password protections is not an issue. If it is, unplug the ethernet cable for a bit:

Reset Mysql Account Root Password

The easiest way is to
  • stop the mysqld service
  • add 'skip-grant-tables=1' to the my.cnf configuration file under the [mysqld] section
  • start the mysqld service
  • connect using 'mysql -u root'
  • do 'use mysql;'
  • do 'update user set password = PASSWORD('new_pwd') where User = 'root';'
  • stop the service again
  • return my.cnf to its original condition
  • restart the mysqld service
  • test with 'mysql -uroot -p' and enter your new password at the prompt

...of course, I have always suspected that access issues in mysql serve the same purpose as the calculus requirement in college CS departments. To weed out the unworthy. ;^)

No comments yet. Be the first.


Add a Comment

  Remember me?:


Previous Item - Return to donmcarthur.com

Top
Mail to mcarthurweb at yahoo dot com
On Freenode IRC #MySQL Channel
as threnody
DIY Blogware by Don McArthur
© 2007 - 2010 Donald W. McArthur