The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
FreeBSD Support
 New Topic  |  Go to Top  |  Go to Topic  |  Search  |  Log In   Previous Message  |  Next Message 
 HowTo: change root mysql password if you lose it
Author: Stephen VanDyke 
Date:   18-10-00 19:48

I had to do this a while ago and thougt it would make a nice howto on the site :)

Cheers,
Stephen VanDyke

-----

Here's a complete howto on what to do if the root password is ever lost/changed and it has to be changed back.

You must be either the Unix root user or the same user the server runs as to do this.

Take down the mysqld server by sending a kill (not kill -9) to the mysqld server.
The pid is stored in a .pid file which is normally in the MySQL database directory:

kill `cat /mysql-data-directory/hostname.pid`

Restart mysqld with the --skip-grant-tables option

/path/to/mysqld --skip-grant-tables

Connect to the mysqld server with mysql -u root

MySQL should drop you straight to the sql command line without prompting for a password

connect to the mysql database with "connect mysql"

Update priveledges on the user you need to regain access to, you may need
to perform a "select * from user" to confirm what accounts they have set-up

"UPDATE user SET password=PASSWORD('newpassword') WHERE user='root';

Flush the priveledges cache that was NOT initially loaded

FLUSH PRIVILEGES;

Log out of MySQL, and attempt to relog in.
mysql -u root -p password newpassword

10. If everything works, kill the current running mysql daemon and restart as you would normally.


 Reply To This Message  |  Forum List  |  Flat View   Newer Topic  |  Older Topic 

 Topics Author  Date
 HowTo: change root mysql password if you lose it   new
Stephen VanDyke 18-10-00 19:48 
 RE: HowTo: change root mysql password if you lose   new
Dan Langille 18-10-00 21:12 


 Forum List  |  Need a Login? Register Here 
 User Login
 User Name:
 Password:
 Remember my login:
   
 Forgot Your Password?
Enter your email address or user name below and a new password will be sent to the email address associated with your profile.
How to get the most out of the forum

phorum.org