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

简介: 虚拟机安装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)
);
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
关系型数据库 MySQL Docker
docker pull mysql:8.0.26提示Error response from daemon: Get “https://registry-1.docker.io/v2/“: EOF错误
docker pull mysql:8.0.26提示Error response from daemon: Get “https://registry-1.docker.io/v2/“: EOF错误
5219 9
|
网络协议 关系型数据库 MySQL
MySQL报ERROR 2002 (HY000)解决
通过上述步骤,可以有效地解决MySQL连接时出现的 `ERROR 2002 (HY000)`错误。这些步骤包括检查和启动MySQL服务、配置文件检查、套接字文件检查、日志文件分析、进程检查、防火墙设置、客户端配置和最终的MySQL重装。确保每个步骤都按顺序执行,有助于快速定位和解决问题,使MySQL服务器恢复正常运行。
11648 0
|
数据安全/隐私保护 虚拟化 Windows
如何在 VM 虚拟机中安装 Windows 7 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 Windows 7 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 Windows 7 操作系统保姆级教程(附链接)
|
数据安全/隐私保护 虚拟化 Windows
如何在 VM 虚拟机中安装 Windows Server 2012 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 Windows Server 2012 操作系统保姆级教程(附链接)
|
数据安全/隐私保护 虚拟化 Windows
如何在 VM 虚拟机中安装 Windows XP 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 Windows XP 操作系统保姆级教程(附链接)
|
Linux 网络安全 数据安全/隐私保护
如何在 VM 虚拟机中安装 CentOS Linux 9 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 CentOS Linux 9 操作系统保姆级教程(附链接)
|
安全 Linux 网络安全
如何在 VM 虚拟机中安装 Red Hat Enterprise Linux 9.3 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 Red Hat Enterprise Linux 9.3 操作系统保姆级教程(附链接)
|
Web App开发 安全 Linux
【独家揭秘2025】VMware Workstation Pro虚拟机:免费安装教程大放送,一键解锁操作系统模拟神器!
VMware Workstation Pro 是由威睿(VMware)公司开发的一款功能强大的桌面虚拟化软件,允许用户在同一台物理计算机上同时运行多个操作系统,如Windows、..
【独家揭秘2025】VMware Workstation Pro虚拟机:免费安装教程大放送,一键解锁操作系统模拟神器!
|
数据可视化 大数据 Linux
OpenEuler虚拟机安装保姆级教程 | 附可视化界面
本文介绍了如何在VMware中安装openEuler操作系统,从选择合适的镜像版本下载开始,到创建虚拟机、配置CPU虚拟化、进行系统安装、设置网络连接,直至安装DDE桌面环境实现图形化操作。openEuler是一款由华为开源的操作系统,支持多种处理器架构,广泛应用于数据库、大数据、云计算等领域。文中还分享了安装过程中的注意事项及解决网络问题的方法,适合初次接触openEuler的用户参考学习。
8010 4
OpenEuler虚拟机安装保姆级教程 | 附可视化界面
|
Unix Linux 开发工具
centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】
本文详细介绍了如何在官网下载CentOS 8以及在VMware Workstation Pro 16虚拟机上安装CentOS 8的步骤,包括可能出现的问题和解决方案,如vcpu-0错误的处理方法。
centos的官网下载和vm16虚拟机安装centos8【保姆级教程图解】

推荐镜像

更多