数据库之MySQL ERROR 1698 (28000) 错误:Access denied for user 'root'@'localhost'" error【摘抄】
2023-09-27 14:24:42 时间
声明:全文均摘抄于MySQL ERROR 1698 (28000) 错误
//错误起源:
~$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
解决步骤:
- 停止mysql服务
~$ sudo service mysql stop
- 以安全模式启动MySQL
~$ sudo mysqld_safe --skip-grant-tables &
- MySQL启动之后就可以不用密码登陆了
~$ 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)
- 查看一下user表,错误的起因就是在这里, root的plugin被修改成了auth_socket,用密码登陆的plugin应该是mysql_native_password。
mysql> select user, plugin from mysql.user;
+-----------+-----------------------+
| user | plugin |
+-----------+-----------------------+
| root | auth_socket |
| mysql.sys | mysql_native_password |
| dev | mysql_native_password |
+-----------+-----------------------+
3 rows in set (0.01 sec)
- 关于auth_socket,在官方有说明: https://dev.mysql.com/doc/mysql-security-excerpt/5.5/en/socket-authentication-plugin.html ,反正现在暂时不用它, 那就把这里改了。
mysql> update mysql.user set authentication_string=PASSWORD('newPwd'), plugin='mysql_native_password' where user='root';#最关键一步骤
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
- 重启服务,问题就解决了
~$ 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)
7.linux云主机端:开启远程连接
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address = 127.0.0.1
sudo service mysql restart
相关文章
- windows下mysql配置
- 【阿里最新数据库面试题】MySQL主从一致性
- mysql 8 集群搭建
- 当用命令导入csv文件时提示错误[Err] 1290 - The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
- MYSQL导入CSV格式文件数据执行提示错误(ERROR 1290): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement.
- 不可不知的 MySQL 升级利器及 5.7 升级到 8.0 的注意事项
- MySQL主从 常见的错误及解决方案
- Mysql:This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME 错误解决
- MySQL删除数据库时的错误
- Linux 下,mysql数据库报无法登陆错误:ERROR 1045 (28000): Access denied for use
- VC连接mysql数据库错误:libmysql.lib : fatal error LNK1113: invalid machine 解决方法
- MySQL 存储过程传参之in, out, inout 参数用法
- ERROR 1366 (HY000): Incorrect string value: ‘xBFxCBxC0xFBxB7xF2...‘ for colum 错误解决方案---mysql
- 2022-12-02 mysql列存储引擎-trigger插入数据错误-记录
- 2023-03-14 mysql-innodb中的锁
- RDS MySQL 全文检索相关问题的处理
- MySQL 错误日志(Error Log)
- mysql-5.7.9-winx64 MySQL服务无法启动,服务没有报告任何错误的解决办法
- 【JAVA百炼成仙】JDBC连接MYSQL数据库
- 将SQL文件导入MySql
- MySQL:主从复制跳过错误
- mysql同步之otter/canal环境搭建完整详细版