How to reset forgotten root password on Ubuntu machine
First stop the mysqld daemon
$ /etc/init.d/mysql stop
Now open the mysql in safe mode
$ /usr/bin/mysqld_safe --skip-grant-tables &
- In safe mode login will not ask for password
Now login MySQL as root
$ mysql --user=root mysql
Enter password: <click enter key>
mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
Query OK, 2 rows affected (0.04 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> exit
Bye
This sets the new password to root.
No comments:
Post a Comment