Under centos7, forget mysql2.5. Version of the login password, how to reset and login
Forget the initial password
1. View the initial password
# grep 'temporary password' / var/log/mysqld.log
2. Log in with the initial password
# mysql-u root-p
3. Change the password
Mysql > ALTER USER 'root' IDENTIFIED BY' xxxxxxxxx'
Mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY' xxxxxxxx'
4. Refresh the permission table
Mysql > flush privileges
5. Exit and restart
Mysql > exit
# service mysqld restart
Forget the modified password
Check if mysql is started, and if so, turn off mysql
/ / View mysql status
# ps-ef | grep mysql
# service mysql stop
Modify the configuration file my.cnf of mysql
In the / etc/my.cnf file, add 2 lines of code
[mysqld]
Skip-grant-tables
The function is to skip password verification when logging in to mysql
3. Start mysql and enter mysql
# service mysqld start
# mysql-u root
Modify the password
Connect to the mysql database and change the user's password
Mysql > use mysql
Mysql > update mysql.user set authentication_string=password ('123456') where user='root'
Mysql > flush privileges
Mysql > exit
Restart mysql
First comment or delete the 2 lines of code that have been added to the configuration file, then restart mysql, and you can log in with the password you just set.
# service mysql start
# mysql-u root-p
Enter password: