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

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 虚拟机安装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)
);
相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
2月前
|
关系型数据库 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错误
|
4月前
|
关系型数据库 MySQL 网络安全
DBeaver连接MySQL提示Access denied for user ‘‘@‘ip‘ (using password: YES)
“Access denied for user ''@'ip' (using password: YES)”错误通常与MySQL用户权限配置或网络设置有关。通过检查并正确配置用户名和密码、用户权限、MySQL配置文件及防火墙设置,可以有效解决此问题。希望本文能帮助您成功连接MySQL数据库。
531 4
|
4月前
|
网络协议 关系型数据库 MySQL
MySQL报ERROR 2002 (HY000)解决
通过上述步骤,可以有效地解决MySQL连接时出现的 `ERROR 2002 (HY000)`错误。这些步骤包括检查和启动MySQL服务、配置文件检查、套接字文件检查、日志文件分析、进程检查、防火墙设置、客户端配置和最终的MySQL重装。确保每个步骤都按顺序执行,有助于快速定位和解决问题,使MySQL服务器恢复正常运行。
2942 0
|
7月前
|
SQL 关系型数据库 MySQL
mysql密码错误-ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using passwor:yes)
这篇文章提供了解决MySQL数据库"Access denied for user 'root'@'localhost' (using password: YES)"错误的方法,通过跳过密码验证、修改root密码,然后重启服务来解决登录问题。
mysql密码错误-ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using passwor:yes)
|
8月前
|
缓存 关系型数据库 MySQL
error: Failed dependencies: mariadb-connector-c-config is obsoleted by mysql-community-server-8.0.36-1.el7.x86_64 问题解决
error: Failed dependencies: mariadb-connector-c-config is obsoleted by mysql-community-server-8.0.36-1.el7.x86_64 问题解决
499 19
|
8月前
|
关系型数据库 MySQL Linux
error: Failed dependencies: libncurses.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 libtinfo.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 如何解决?
error: Failed dependencies: libncurses.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 libtinfo.so.5()(64bit) is needed by mysql-community-client-8.0.36-1.el7.x86_64 如何解决?
1239 3
|
8月前
|
关系型数据库 MySQL 测试技术
MySQL 报错 ERROR 1709: Index column size too large
MySQL 报错 ERROR 1709: Index column size too large
352 4
|
7月前
|
关系型数据库 MySQL Java
【Azure 应用服务】应用服务连接 Azure MySQL 一直失败,报错 Create connection error
【Azure 应用服务】应用服务连接 Azure MySQL 一直失败,报错 Create connection error
|
8月前
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file
829 2
|
8月前
|
安全 关系型数据库 MySQL
【Python】已解决:pymysql.err.OperationalError:(2003 “Can’t connect to MySQL server on ‘localhost’ ([WinEr
【Python】已解决:pymysql.err.OperationalError:(2003 “Can’t connect to MySQL server on ‘localhost’ ([WinEr
1123 1