- vi /etc/my.cnf, add [mysqld] in
skip-grant-tables
E.g:
[mysqld]
skip-grant-tables
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
- Restart mysql
service mysql restart
- Use of non-logged-on user password
mysql -uroot -p (click on the Enter password is blank)
- Select Database
use mysql;
- Changing the root password
update user set authentication_string=password('123456') where user='root';
6. Refresh rights
flush privileges;
7. Quit
exit;
8. Delete the first increase in a configuration information
skip-grant-tables
9. Restart mysql
service mysql restart