Advertisement
pebriana

Reset Forgotten MySQL Root Password

Oct 22nd, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. Have you ever forgotten the root password on one of your MySQL servers? No? Well maybe I’m not as perfect as you. This is a quick h00tow (how to) reset your MySQL root password. It does require root access on your server. If you have forgotten that password wait for another article. Original article posted on reset mysql root password.
  2.  
  3. First things first. Log in as root and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.
  4.  
  5. mysqld_safe --skip-grant-tables
  6.  
  7. You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.
  8.  
  9. mysql --user=root mysql
  10.  
  11. update user set Password=PASSWORD('new-password') where user='root';
  12. flush privileges;
  13. exit;
  14.  
  15. Now kill your running mysqld, then restart it normally. You should be good to go. Try not to forget your password again.
  16.  
  17.  
  18. also can by
  19. $ /usr/bin/mysqladmin -u root password 'new-password'
  20.  
  21. ============================================
  22. http://ubuntu.flowconsult.at/en/mysql-set-change-reset-root-password/
  23. ============================================
  24.  
  25. Tested on
  26. - Ubuntu Linux 7.10 Gutsy Gibbon and MySQL 5.0.45. (2007-10-21)
  27. - Ubuntu Linux 6.06 Dapper Drake and MySQL 4.1.15.
  28.  
  29. Set / change / reset the MySQL root password on Ubuntu Linux. Enter the following lines in your terminal.
  30. Stop the MySQL Server.
  31. sudo /etc/init.d/mysql stop
  32.  
  33. Start the mysqld configuration.
  34. sudo mysqld --skip-grant-tables &
  35.  
  36. Login to MySQL as root.
  37. mysql -u root mysql
  38.  
  39. Replace YOURNEWPASSWORD with your new password!
  40. UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root'; FLUSH PRIVILEGES; exit;
  41.  
  42. Note: This method is not regarded as the securest way of resetting the password. However it works.
  43.  
  44.  
  45. References
  46.  
  47. MySQL 5.0 Reference Manual: How to Reset the Root Password
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement