Use mysql for the first time after installation mysql -uroot -p
root
MySQL ERROR 1698 (28000) ....
sudo mysql -uroot goes in
update mysql.user set password=PASSWORD('root') where User='root';
Reboot after changing the password
root login prompt password error
Baidu
After mysql 5.7, if you forget your password and change your password, the password column is no longer Password, but authentication_string
Solution steps:
stop mysql service
~$ sudo service mysql stop
Start MySQL in Safe Mode
~$ sudo mysqld_safe --skip-grant-tables &
Here may prompt that mysqld_safe already exists
I can't turn it off with kill -9 but restart it
Start MySQL in safe mode after reboot
After MySQL starts, you can log in without a password
mysql -uroot
Modify the root password and plugin
update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root';
restart the service
can log in successfully