Forgot root password in mysql? Confused how to reset it? After googling here and there, here I will discuss how to reset root password in mysql. There are two methods or two ways to reset the root password in mysql, and dua2nya I have tried. Ok we directly discuss here ...
First way:
Login as root and stop service mysql :
#/etc/init.d/mysql stop
#killall mysqld
Restart mysql with the - skip-grant-tables
#mysqld_safe --skip-grant-tables &
Log into the mysql shell :
#mysql
mysql>
note: if you can not get into the shell mysql command means there is an error, pleaserepeat the above command in order.
Password reset with the command :
mysql>UPDATE mysql.user SET Password=PASSWORD('yournewpassword') WHERE User='root' AND Host='localhost';
mysql> FLUSH PRIVILEGES;
mysql>QUIT
note: if the command above is true then it will appear 'Query OK ....'
Restart mysql:
# killall mysqld
# /etc/init.d/mysql restart
Finish