Solution to MySql Error 1698 of 28000 Problem
- 2021-08-21 21:41:06
- OfStack
1. Problem description:
MysqlERROR1698 (28000) solves the problem that mysql-server-5. 7 is newly installed. Ordinary users can't enter mysql, only root users can enter, and no password is needed.
~$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
2. Solution steps:
Stop mysql service
~$ sudo service mysql stop
Start MySQL in Safe Mode
~$ sudo mysqld_safe --skip-grant-tables &
After MySQL is started, you can log in without password
~$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)
Look at the user table under 1. The cause of the error is here. plugin of root has been modified to auth_socket, and plugin logged in with password should be mysql_native_password.
mysql> select user, plugin from mysql.user;
+-----------+-----------------------+
| user | plugin |
+-----------+-----------------------+
| root | auth_socket |
| mysql.sys | mysql_native_password |
| dev | mysql_native_password |
+-----------+-----------------------+
<strong>3</strong> rows in set (<strong>0.01</strong> sec)
As for auth_socket, there is an official explanation: https://dev.mysql.com/doc/mysql-security-excerpt/5. 5/en/socket-authentication-ES50html. Anyway, it is not used for the time being, so change it here.
mysql> update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root';
Query OK, <strong>1</strong> row affected, <strong>1</strong> warning (<strong>0.00</strong> sec)
Rows matched: <strong>1</strong> Changed: <strong>1</strong> Warnings: <strong>1</strong>
mysql> flush privileges;
Query OK, <strong>0</strong> rows affected (<strong>0.00</strong> sec)
Restart the service and the problem is solved
~$ sudo service mysql stop
...
* MySQL Community Server 5.7.10 is stopped
~$ sudo service mysql start
..
* MySQL Community Server 5.7.10 is started
~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.10 MySQL Community Server (GPL)