Before the MySQL server to use the password to log on to the root account is not a problem, but today do not know because of the move, landing failed and there is this error code:
~$ mysql-u Root-1698 (28000for'root' localhost '
Steps to resolve:
Stop MySQL Service
sudo service MySQL stop
Start MySQL in safe mode
sudo mysqld_safe--skip-grant-tables &
After MySQL starts, you can log in without a password.
~$ mysql-u rootwelcome to the MySQL monitor. ID 2 5.7. MySQL Community Server (GPL)
Look at the user table, the cause of the error is here, the root of the plugin has been modified to auth_socket, the password to log on the plugin should be mysql_native_password.
Mysql> Select User, plugin fromMysql.User;+-----------+-----------------------+| User |Plugin|+-----------+-----------------------+|Root|Auth_socket||Mysql.sys|Mysql_native_password||Dev|Mysql_native_password|+-----------+-----------------------+3Rowsinch Set(0.01Sec
About Auth_socket, in the official note: https://dev.mysql.com/doc/mysql-security-excerpt/5.5/en/socket-authentication-plugin.html , but now it is not used for the time being, change it here.
Mysql> UpdateMysql.User SetAuthentication_string=PASSWORD ('newpwd'), plugin='Mysql_native_password' where User='Root'; Query OK,1Row affected,1Warning (0.00sec) Rows matched:1Changed:1Warnings:1MySQL>FlushPrivileges; Query OK,0Rows Affected (0.00Sec
Restart the service, the problem is solved
sudo5.7. Ten Is stopped sudo 5.7. Ten Is started~$ mysql-u root –penter password:welcome to the MySQL monitor. ID 2 5.7. MySQL Community Server (GPL)
MySQL Error 1698 (28000) errors