Enter mysql with this command
sudo mysql
Enter the following command on the sql command line and press Enter, you can change the password to mynewpassword
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';
exit to return to the terminal command line, enter:
exit;
sudo mysql_secure_installation
Just enter the password just now.
Choose n for any problems that arise.