First of all I have to say I am a little two, this can forget .....
Method One:
#/etc/init.d/mysqld Stop
# Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
# mysql-uroot MySQL
mysql> Update user Set Password=password (' NewPassword ') where user= ' root ';
mysql> flush Privileges;
Mysql> quit
#/etc/init.d/mysql Restart
# mysql-uroot-p
Enter Password:
Method Two:
To modify the login settings for MySQL:
# VI/ETC/MY.CNF
Add a sentence to the paragraph in [mysqld]: Skip-grant-tables
As follows:
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
Skip-grant-tables
Restart MySQL
#/etc/init.d/mysqld Restart
Stopping mysqld: [OK]
Starting mysqld: [OK]
No password login:
# MySQL
mysql> use Mysql;update user set Password=password (' root ') where user= ' root ';
mysql> flush Privileges;
Exit, modify/etc/my.conf, delete skip-grant-tables, restart MySQL. Get
Mysql root password forgot what to do