Difference between revisions of "Lost MySQL root password?"

From Kolmisoft Wiki
Jump to navigationJump to search
(New page: Ok, if this is your only problem this little trick will show how to recover your root password. Proceed as follows. * Stop the db engine /etc/init.d/mysql stop * Restart the daemon...)
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Ok, if this is your only problem this little trick will show how to recover your root password.
/etc/init.d/mysql stop


Proceed as follows.
mysqld_safe --skip-grant-tables &
[1] 2429
morgui:~# Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[2466]: started


* Stop the db engine
Window hangs, we go to other console


    /etc/init.d/mysql stop
mysql -u root


* Restart the daemon
use mysql;


    /usr/bin/mysqld_safe –skip-grant-tables &
update user set password=PASSWORD('''""''') where user='root';


* Go to the MySQL interactive command
Type your password there inside of those quotes, for example PASSWORD('''"my_new_password"''')


    mysql -h your_hostname mysql
flush privileges;


* Change the password with the GRANT command
quit;


    GRANT ALL PRIVILEGES ON * to root@localhost IDENTIFIED BY ‘passwd’;
Back to previous console:
    FLUSH PRIVILEGES;


Maybe it should be better to flush privileges from mysqladmin:
quit;


    mysqladmin -h localhost flush-privileges
/etc/init.d/mysql restart


That’s it. Now try to login as usual.


----
<br><hr><br>


Pasted from: http://www.karkomaonline.com/index.php/2003/08/10/lost-mysql-root-password/
http://www.debianhelp.co.uk/mysqlroot.htm

Latest revision as of 10:58, 13 January 2010

/etc/init.d/mysql stop

mysqld_safe --skip-grant-tables &
[1] 2429
morgui:~# Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[2466]: started

Window hangs, we go to other console

mysql -u root
use mysql;
update user set password=PASSWORD("") where user='root';

Type your password there inside of those quotes, for example PASSWORD("my_new_password")

flush privileges;
quit;

Back to previous console:

quit;
/etc/init.d/mysql restart





http://www.debianhelp.co.uk/mysqlroot.htm