After MySQL installation, MySQL command line login MySQL prompt following error:
Access denied for user ' root ' @ ' localhost ' (using Password:yes)
The possible reason is that you do not know the root password caused.
You can modify the root user password using the following methods:
1. Modify the service startup parameters
sudo vi/usr/lib/systemd/system/mysqld.service
Start command plus skip-grant-tables parameter
Execstart=/usr/bin/mysqld_safe--skip-grant-tables
2, the implementation of Daemon-reload
sudo systemctl daemon-reload
3. Restart MySQL Service
sudo systemctl restart mysqld
4. Log in to MySQL using the root user
Mysql-uroot
5. Change the root password
Use MySQL;
Update user set Password=password ("123456") where user= ' root ';
6. Refresh Permissions
Refresh permissions when password is modified
Flush privileges;
7. Remove the skip-grant-tables of the service startup parameters and restart
The start command is modified to:
Execstart=/usr/bin/mysqld_safe
After the modification, the execution
sudo systemctl daemon-reload
sudo systemctl restart mysqld
After rebooting, you can log in using root/123456.
Change the root password of MySQL under CentOS