MySQL root password recovey Print E-mail
Written by Administrator   
Monday, 04 December 2006
This tutorial is written in two ways. One way is for the compiled MySQL and one for the installed MySQL by RPM [tested only in Fedora]. It's not a big deal, but I hope it is accessible also to newbies because the directory's change in both examples.

--------------------
If you compiled MySQL by yourself, go this way:

Maybe you have to change the directory where you installed MySQL (here it's /usr/local/mysql/ ).

1. Gain root access to your Linux system
[boby@space boby]$ su -
Password:
[root@space root]#
2. First you have to stop the daemon
[root@space root]# /etc/init.d/mysql.server stop
[root@space root]#
3. You will now start MySQL in safe mode without reading the grant tables with all MySQL database passwords and also you will disable networking. The "safe_mysqld" command will do this trick for you.
[root@space root]# /usr/local/mysql/bin/safe_mysqld --user=mysql --skip-grant-tables --skip-networking &
[root@space root]#
4. The "mysqladmin" command can now reset the root password. In this case we are setting it to "newpassword".
[root@space root]# /usr/local/mysql/bin/mysqladmin -u root flush-privileges password "newpassword"
[root@space root]#
5. And finally restart the daemon
[root@space root]# /etc/init.d/mysql.server restart
[root@space root]#
6. You can use now your new root password
[root@space root]# /usr/local/mysql/bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.0.20-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

--------------------
If you installed MySQL by RPM or use the package that comes with the distribution, go this way:

1. Gain root access to your Linux system
[boby@space boby]$ su -
Password:
[root@space root]#
2. First you have to stop the daemon
[root@space root]# /etc/init.d/mysqld stop
[root@space root]#
3. You will now start MySQL in safe mode without reading the grant tables with all MySQL database passwords and also you will disable networking. The "safe_mysqld" command will do this trick for you.
[root@space root]# /usr/bin/safe_mysqld --user=mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --datadir=/var/lib/mysql
--skip-grant-tables --skip-networking &
[root@space root]#
4. The "mysqladmin" command will now reset[rewrite] the root password. In this case we are setting it to "newpassword".
[root@space root]# mysqladmin -u root flush-privileges password "newpassword"
[root@space root]#
5. Stop the running daemon
kill `cat /var/run/mysqld/mysqld.pid`
6. And finally restart it
[root@space root]# /etc/init.d/mysqld start
[root@space root]#
7. You can use now your new root password
[root@space root]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 4.0.20-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
--------------------
Add as favourites (53) | Quote this article on your site | Views: 502

Be first to comment this article
RSS comments

Write Comment
  • Please keep the topic of messages relevant to the subject of the article.
  • Personal verbal attacks will be deleted.
  • Please don't use comments to plug your web site. Such material will be removed.
  • Just ensure to *Refresh* your browser for a new security code to be displayed prior to clicking on the 'Send' button.
  • Keep in mind that the above process only applies if you simply entered the wrong security code.
Name:
E-mail
Homepage
Title:
BBCode:Web AddressEmail AddressLoad Image from WebBold TextItalic TextUnderlined TextQuoteCodeOpen ListList ItemClose List
Comment:



Code:* Code
I wish to be contacted by email regarding additional comments

Powered by AkoComment Tweaked Special Edition v.1.4.5

Last Updated ( Friday, 16 February 2007 )
 
< Prev   Next >
Main Menu
Home
Our Services
Contact Us
Search
News Feeds
Our offers
Linux Tutorials
Affiliate program
Links
CarTube.co.cc
PetTube.co.cc
Slick RSS
GetAFreelancer.com New Projects
Latest projects published at GetAFreelancer.com
ScriptLance Projects
The newest projects posted on ScriptLance.
Google AdSense
Last comments
Howto install memcached, setup...
Thanks! :)
08/05/08 09:38 More...
By Jupp

Howto install memcached, setup...
wery good site
26/01/08 12:18 More...
By u26stycznia2008

Script installation Services
Comment 13 2008
Helo1l, great site!
13/10/07 10:10 More...
By John 200809

Visitors Counter
73811 Visitors
Joomla Template by Joomlashack
components joomla modules Joomla Templates Joomla tutorials