MySql on Fedora: lost root password
i've personally never ever faced with this problem, that I've completely lost the control over MySql. Somehow - I dunno how - I totaly locked out myself from the database :)
I found some information on the web on how to deal with this problem, but I have a solution for other Fedora users, because none of the others' will work on this installation:
1) You need to completely stop MySql.
Running
service mysqld stop
is not enough, you need to type the following (with root or with the mysql user): kill `cat /var/run/mysqld/mysqld.pid`
2) If nothing shows up on the screen, this is golden silence - so you were successful. If you see a 'cat: var/run/mysql/mysqld.pid: No such file or directory' error, then please run: slocate .pid
(you need to have slocate installed either by apt-get or yum) - it will show up the list of all pid files on your server - there you can find out, where mysqld stores its.
3) A new mysqld must be started with the parameter --skip-grant-tables
.
The main problem is, that other distributions have the safemode version under the name mysqld_safe, but under Fedora, of course it is safe_mysqld...
So type in the following: safe_mysqld --skip-grant-tables &
Now the server replied with someting like the following: Starting mysqld daemon with databases from /var/lib/mysql.
4) Enter: mysql -u root
5) Execute the following SQL: UPDATE mysql.user SET Password=PASSWORD('your-new-password') WHERE User='root';
(you need to change the your-new-password string to the desired root password)
6) Then: FLUSH PRIVILEGES;
Now you'll have a clean and newly passed root acount to your own server ;) Easy, isn't it?
Comments
Thank you. I did however use
brasilghana# mysqld_safe --skip-grant-tables &
in my Fedora Core 4
Thank you. I did however use
brasilghana# mysqld_safe --skip-grant-tables &
in my Fedora Core 4
In Fedora 18 I did
Amit Chavan1. service mysqld stop
2. mysqld_safe --skip-grant-tables &
3. mysql -u root
4. UPDATE mysql.user SET Password=PASSWORD(''root'') WHERE User=''root'';
5. FLUSH PRIVILEGES;
6. service mysqld start
7. mysql -uroot -p
Enter password:
8. mysql>