1. First enter the MySQL environment
mysql -h localhost -p3306 -u root -p
prompt for password
Enter password: *******
2. Modify the password:
First enter: flush privileges;
flush privileges;
Then enter: ALTER USER 'root'@'localhost' IDENTIFIED BY '12345';
ALTER USER 'root'@'localhost' IDENTIFIED BY '12345';
[ 12345 is the new password]