- You just installed MySQL (I'm worked with 5.70) on linux machine. You want to chagne root password and want to use password to login instead of login via sudo.
- Login to mysql as root
sudo mysql -u root
- Execute:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<your_password>';
This command will:
IDENTIFIED WITH mysql_native_password
: Allow you to login via password. (But you won't be able to login by sudo)- Change root password to <your_password>