虚拟机安装MYSQL后不知道密码打开 ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘

本文涉及的产品
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用版 2核4GB 50GB
简介: 虚拟机安装MYSQL后不知道密码打开 ERROR 1698 (28000): Access denied for user ‘root‘@‘localhost‘

1.删data

2.初始化

3.找err

yq@gyq-virtual-machine:~$ mysql -u root -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'


加上这一句


gyq@gyq-virtual-machine:~$ sudo mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.03 sec)
mysql>


8版本密码不知道的话

mysql -u root -p

设置密码:

set password for 'root'@'localhost'='123';

寻找虚拟机的mysql的安装路径

40.1.png40.2.png40.3.png40.4.png

2022-04-14 09:22:27 INFO  StateStoreCoordinatorRef:54 - Registered StateStoreCoordinator endpoint
Exception in thread "main" java.sql.SQLException: Access denied for user 'root'@'localhost'
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:829)
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:449)
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:242)
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198)
    at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils
anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:63)atorg.apache.spark.sql.execution.datasources.jdbc.JdbcUtils
anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:63)atorg.apache.spark.sql.execution.datasources.jdbc.JdbcUtils
anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:54)
    at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:56)
    at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation.<init>(JDBCRelation.scala:115)
    at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:52)
    at


这个是密码账号不对,自己改


update user set authentication string='' where user= 'root';
ALTER user 'root' @'localhost' IDENTIFIED BY‘123456';
ALTER USER 'root'@'localhost' IDENTIFIED BY 'QQ3154067760!!!';
use mysql; ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; flush privileges; quit;
update user set authentication_string='' where user='root';
mysql> flush privileges ;
mysql>quit
2022-04-14T05:34:48.181552Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: <%2qvHuBt7Bu
MySQL修改初始密码三种方法:
方法一:
1、使用空的初始密码登录mysql账号:
mysql-uroot -p
2、修改root密码:
SETPASSWORD = PASSWORD('123456');
方法二:
1、使用空的初始密码登录mysql账号:
mysql-uroot -p
2、修改root密码:
mysqladmin -u root password '123456'
方法三:
1、使用空的初始密码登录mysql账号:
mysql-uroot -p
2、修改root密码:
mysql> update user set Password=password("123456") where User='root';
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)
mysql> select Host,User,password from user where user='root';
+-----------------------+------+-------------------------------------------+
| Host | User | password |
+-----------------------+------+-------------------------------------------+
| localhost | root | *5626ED34B75C6C508BA2A3D0A4F6E4C58823138C |
| localhost.localdomain | root | *5626ED34B75C6C508BA2A3D0A4F6E4C58823138C |
| 127.0.0.1 | root | *5626ED34B75C6C508BA2A3D0A4F6E4C58823138C |
| ::1 | root | *5626ED34B75C6C508BA2A3D0A4F6E4C58823138C |
+-----------------------+------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql 5.7的数据库没有了password字段,用的是authentication_string字段:
mysql> update mysql.user set authentication_string=password('root') where user='root' ;
mysql> flush privileges;
mysql 8.0.13的数据库用的也是authentication_string字段:
mysql> update mysql.user set authentication_string='******' where user='root' ;
mysql> flush privileges;
参考:
https://www.cnblogs.com/jimmyTang-J/p/9698211.html
https://blog.csdn.net/xuheng8600/article/details/80034647
https://blog.csdn.net/z13615480737/article/details/78907697
======================================================================
1页
初始密码为空,使用空密码登陆mysql执行下列语句
mysql>use mysql;
mysql> UPDATE user SET password=PASSWORD(root) WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> quit;
修改/opt/lampp/phpmyadmin/config.inc.php
找到如下代码:
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]==================================================================
update user set authentication_string=PASSWORD('123456') where user='root';我个
gyq@gyq-virtual-machine:/etc/mysql$ cat debian.cnf
cat: debian.cnf: 权限不够
gyq@gyq-virtual-machine:/etc/mysql$ sudo cat debian.cnf
[sudo] gyq 的密码: 
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = dOv1YXqIEXueQbJL
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = dOv1YXqIEXueQbJL
socket   = /var/run/mysqld/mysqld.sock
gyq@gyq-virtual-machine:/etc/mysql$ mysql -uroot -p
Enter password: 
ERROR 1698 (28000): Access denied for user 'root'@'localhost'
gyq@gyq-virtual-machine:/etc/mysql$ mysql -u debian-sys-maint -p dOv1YXqIEXueQbJL
Enter password: 
ERROR 1049 (42000): Unknown database 'dOv1YXqIEXueQbJL'
gyq@gyq-virtual-machine:/etc/mysql$ mysql -u debian-sys-maint -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set authentication_string=PASSWORD("123456") where user='root';
ERROR 1064 (42000): You have an error in your 
-----------------------------------------------------------------------------------------------------------------------------
第一步:进入目录:cd /etc/mysql,查看debian.cnf文件第二步:使用上图中的账号密码登录MySQL。第三步:查看数据库中的库。
第四步:使用mysql库。
第五步:使用一下语句设置账号密码:update user set authentication_string=PASSWORD("自定义新密码") where user='root';我个人设置的简单。账号为:root。
 密码:123456.第六步:执行一下语句:update user set plugin="mysql_native_password";第七步:刷新:flush privileges;第八步:退出:quit;第九步:修改密码完成。
在命令框中输入:/etc/init.d/mysql restart; 重启MySQL
------------------------------------————————————————————————————————————————————————————————————+++
create table user_test (
name varchar(64),
age int(11)
)
CREATE TABLE St(
bname CHAR(10) PRIMARY KEY, 
number CHAR(10)
);
相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
11天前
|
关系型数据库 MySQL 数据安全/隐私保护
windows mysql8 安装后 提示密码不对,修改下密码认证方式就可以了
windows mysql8 安装后 提示密码不对,修改下密码认证方式就可以了
22 3
|
10天前
|
关系型数据库 MySQL Linux
Linux部署实战前言,MySQL在CentOS安装【单机软件】,MySQL的安装需要root权限,yum install mysql,systemctl enable mysqld开机自启的意思
Linux部署实战前言,MySQL在CentOS安装【单机软件】,MySQL的安装需要root权限,yum install mysql,systemctl enable mysqld开机自启的意思
|
10天前
|
Ubuntu 关系型数据库 MySQL
MySQL5.7在Ubuntu安装[单机软件],第一步登录root,sudo su -
MySQL5.7在Ubuntu安装[单机软件],第一步登录root,sudo su -
|
12天前
|
关系型数据库 MySQL 数据库
mysql 中登录报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)ERROR
mysql 中登录报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)ERROR
|
9天前
|
存储 关系型数据库 MySQL
探索MySQL:关系型数据库的基石
MySQL,作为全球最流行的开源关系型数据库管理系统(RDBMS)之一,广泛应用于各种Web应用、企业级应用和数据仓库中
|
6天前
|
关系型数据库 MySQL 网络安全
Mysql 数据库主从复制
在MySQL主从复制环境中,配置了两台虚拟机:主VM拥有IP1,从VM有IP2。主VM的`my.cnf`设置server-id为1,启用二进制日志;从VM设置server-id为2,开启GTID模式。通过`find`命令查找配置文件,编辑`my.cnf`,在主服务器上创建复制用户,记录二进制日志信息,然后锁定表并备份数据。备份文件通过SCP传输到从服务器,恢复数据并配置复制源,启动复制。检查复制状态确认运行正常。最后解锁表,完成主从同步,新用户在从库中自动更新。
916 6
Mysql 数据库主从复制
|
7天前
|
缓存 运维 关系型数据库
数据库容灾 | MySQL MGR与阿里云PolarDB-X Paxos的深度对比
经过深入的技术剖析与性能对比,PolarDB-X DN凭借其自研的X-Paxos协议和一系列优化设计,在性能、正确性、可用性及资源开销等方面展现出对MySQL MGR的多项优势,但MGR在MySQL生态体系内也占据重要地位,但需要考虑备库宕机抖动、跨机房容灾性能波动、稳定性等各种情况,因此如果想用好MGR,必须配备专业的技术和运维团队的支持。 在面对大规模、高并发、高可用性需求时,PolarDB-X存储引擎以其独特的技术优势和优异的性能表现,相比于MGR在开箱即用的场景下,PolarDB-X基于DN的集中式(标准版)在功能和性能都做到了很好的平衡,成为了极具竞争力的数据库解决方案。
|
12天前
|
XML Java 关系型数据库
Action:Consider the following: If you want an embedde ,springBoot配置数据库,补全springBoot的xml和mysql配置信息就好了
Action:Consider the following: If you want an embedde ,springBoot配置数据库,补全springBoot的xml和mysql配置信息就好了
|
12天前
|
关系型数据库 MySQL 数据库
关系型数据库mysql数据增量恢复
【7月更文挑战第3天】
126 2
|
12天前
|
关系型数据库 MySQL Shell
关系型数据库mysql数据完全恢复
【7月更文挑战第3天】
83 2