First log in to mysql:
mysql -uroot -p
Next we will change the password
mysql>use mysql;
mysql>update user set authentication_string=password('新密码') where user='root';
Note: You may encounter such a problem. This is because your password is not strong enough. Please modify the strength, for example: @ROOT_root_123
It’s not completely done yet, do not exit, here is just a modification, not saved yet,
continue to enter the following command:
mysql> flush privileges;
mysql> quit;
Well, you're done, modify the configuration file back, comment out skip-grant-tables, and restart,
sudo service mysql restart