Sometimes you may forget the root password of MySQL, and the following will teach you to reset the MySQL root user password
Manually Modify
1. Stop MySQL Service
Execution:/etc/init.d/mysql stop, your machine is not necessarily/etc/init.d/mysql or/etc/init.d/mysqld.
Anyway, stop the database, kill the process number can also Ps–ef | grep MySQL and then kill-9 the MySQL process number
2. Skip verification to start MySQL
/usr/local/mysql/bin/mysqld_safe--skip-grant-tables >/dev/null 2>&1 &
Note: If the location of the Mysqld_safe is not the same as above need to be modified to your, if not clear can be found with the Find command.
Find/-name Mysqld_safe
3. Reset Password
Then execute: mysql-u root MySQL
When the MySQL prompt appears, enter: Update user Set password = password (' Password to set ') where user = ' root ';
Enter after execution: flush privileges; Refreshes the MySQL system permissions related tables. Re-execution: exit; Exit.
4. Restart MySQL
Kill MySQL Process: Killall mysqld
Start Mysql:/etc/init.d/mysql Start
So that the MySQL password is reset.
If you are interested in this, please scan the QR code below for free for more details
Linux/centos resetting the MySQL root user password