mysql 5.7 ERROR 1045 (28000): Access denied for user 'root'@'localhost'

滴滴开源的Dokit,除了悬浮窗,它的AOP插件还能帮你监控‘慢函数’和大图加载 本文深入解析滴滴开源的Dokit AOP插件,重点介绍其在Android应用开发中的慢函数监控和大图检测功能。通过无侵入式监控和字节码插桩技术,Dokit帮助开发者高效定位性能瓶颈,优化应用性能。文章还提供了详细的配置指南和实战案例,助力开发者快速掌握这一开源库的高级特性。 阅读详情

mysql 安装了最新版,但是初始化登陆不了,网上找了很多资料,但是都没用,后来在网上看到说是新版本的mysql初始化安装会随机生成一个root密码,如果你不知道这个密码,或者没有留意到这个密码,则会出现我这样的情况,安装了登不了,总是报错:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

或者

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


mysql 版本:

[root@master make]# mysql -V

mysql  Ver 14.14 Distrib 5.7.14, for Linux (x86_64) using  EditLine wrapper


[root@master make]# mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

[root@master make]# mysql -uroot -p
Enter password: [直接回车]
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

以上咋都登陆不了。


下面就是找这个随机生成的密码:

[root@master make]# cat /etc/my.cnf 

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[client]
[mysqld]
#skip-grant-tables
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock


# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0


log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


注意到这一行:

log-error=/var/log/mysqld.log


[root@master make]# head -100 /var/log/mysqld.log 
2016-08-16T15:26:28.672682Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-16T15:26:30.315620Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-08-16T15:26:30.613729Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-08-16T15:26:30.766670Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ce9fd1a4-63c5-11e6-91e7-14dae97164e1.
2016-08-16T15:26:30.791134Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-08-16T15:26:30.791808Z 1 [Note] A temporary password is generated for root@localhost: q+673+g>+=lW
2016-08-16T15:26:44.292088Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-08-16T15:26:44.294757Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.14) starting as process 16748 ...
2016-08-16T15:26:44.298157Z 0 [Note] InnoDB: PUNCH HOLE support available
2016-08-16T15:26:44.298195Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-08-16T15:26:44.298202Z 0 [Note] InnoDB: Uses event mutexes
2016-08-16T15:26:44.298207Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2016-08-16T15:26:44.298211Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-08-16T15:26:44.298215Z 0 [Note] InnoDB: Using Linux native AIO
2016-08-16T15:26:44.298434Z 0 [Note] InnoDB: Number of pools: 1
2016-08-16T15:26:44.298517Z 0 [Note] InnoDB: Using CPU crc32 instructions
2016-08-16T15:26:44.300427Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2016-08-16T15:26:44.310554Z 0 [Note] InnoDB: Completed initialization of buffer pool
2016-08-16T15:26:44.313035Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2016-08-16T15:26:44.326783Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2016-08-16T15:26:44.432774Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2016-08-16T15:26:44.432989Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2016-08-16T15:26:44.916314Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2016-08-16T15:26:44.917405Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2016-08-16T15:26:44.917423Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2016-08-16T15:26:44.917756Z 0 [Note] InnoDB: Waiting for purge to start
2016-08-16T15:26:44.967968Z 0 [Note] InnoDB: 5.7.14 started; log sequence number 2525737
2016-08-16T15:26:44.968208Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2016-08-16T15:26:44.968362Z 0 [Note] Plugin 'FEDERATED' is disabled.
2016-08-16T15:26:44.970151Z 0 [Note] InnoDB: Buffer pool(s) load completed at 160816 23:26:44
2016-08-16T15:26:44.973702Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2016-08-16T15:26:44.973914Z 0 [Warning] CA certificate ca.pem is self signed.
2016-08-16T15:26:44.975822Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2016-08-16T15:26:44.975922Z 0 [Note] IPv6 is available.
2016-08-16T15:26:44.975934Z 0 [Note]   - '::' resolves to '::';
2016-08-16T15:26:44.975957Z 0 [Note] Server socket created on IP: '::'.
2016-08-16T15:26:44.998808Z 0 [Note] Event Scheduler: Loaded 0 events
2016-08-16T15:26:44.998999Z 0 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.7.14'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
2016-08-16T15:26:54.409735Z 2 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-08-16T15:27:01.473344Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO)
2016-08-16T15:27:12.888399Z 4 [Note] Access denied for user 'root'@'localhost' (using password: YES)
2016-08-16T15:27:28.039559Z 5 [Note] Access denied for user 'root'@'localhost' (using password: YES)


其中能够找到这样一行:

2016-08-16T15:26:30.791808Z 1 [Note] A temporary password is generated for root@localhost: q+673+g>+=lW

q+673+g>+=lW  这个就是随机生成的密码啊。

下面测试:

[root@master make]# mysql -uroot -p'q+673+g>+=lW'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 5.7.14


Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.


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;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

这里是因为密码不符合规则,这个与validate_password_policy的值有关。

validate_password_policy有以下取值:

Policy Tests Performed
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file

默认是1,即MEDIUM,所以刚开始设置的密码必须符合长度,且必须含有数字,小写或大写字母,特殊字符。

有时候,只是为了自己测试,不想密码设置得那么复杂,譬如说,我只想设置root的密码为123456。

必须修改两个全局参数:

首先,修改validate_password_policy参数的值

mysql> select @@validate_password_length;
+----------------------------+
| @@validate_password_length |
+----------------------------+
|                          8 |
+----------------------------+
1 row in set (0.03 sec)

mysql> alter user 'root'@'localhost' identified by 'root123456';
Query OK, 0 rows affected (0.00 sec)


至此问题已经解决。



ubuntu 16.04安装mysql5.7.17后,登录时出现ERROR 1045 (28000): Access denied for user 'root'@'localhost' 问题解决! 一、问题描述     今天,笔者为了练习sql,在ubuntu16.04上安装了mysql。笔者在网上搜索了在ubuntu16.04安装mysql的步骤,并跟着步骤一步步操作,然而,让笔者无法明白的是,网上说在安装mysql的过程会弹出输入密码的窗口,然而笔者在安装的过程中没有弹出任何窗口,而且也没有报错。正当笔者在登录mysql时,问题就出现了,如图: 如图,笔者尝试多种输入方式,但都得 阅读详情

相关推荐

NRF52832调试方法1——HardFault_Handler问题定位

一、遇到问题 keil debug模式下,直接点击全速运行(Run)发现程序卡死,点击stop按钮后,停到了HardFault_Handler位置,如下图所示。 此时使用navigate backwards(蓝色左箭头)是无效的,找不到程序卡在哪里。 二、解决办法 此时首先观察register窗口 若Stack为MSP,则复制R13(SP)的值到memory观察窗的地址搜索栏。每一行显示连续的28个地址上的存储信息,每个地址上存有一个字节。 从第21个位置起的连续四个字节是LR的值,

小梁的博客 3650

mysql 使用临时密码登录不进去ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

人生苦短,何妨一试 3519

Intel Arc显卡玩《三角洲行动》报错?手把手教你修改注册表跳过验证

本文针对Intel Arc显卡用户在运行《三角洲行动》时遇到的驱动验证报错问题,提供了详细的解决方案。通过安全修改Windows注册表,添加特定键值以跳过游戏驱动兼容性验证,并结合游戏内图形设置与Intel驱动面板的优化建议,旨在帮助玩家顺利进入游戏并提升游戏帧率与运行稳定性。

weixin_29310605的博客 695

Linux中mysql密码重置

主要是为了解决MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)   该错误发生于密码输入错误时,所以需要对密码进行重置。 第一种情况:你刚刚安装mysql,没有修改过初始/动态密码。 这种情况下mysql会自动生成一个动态密码,你找到该动...

Ace_2的博客 8209

SecureCRT多种配色方案配置文件

位置 C:\Users%USERNAME%\AppData\Roaming\VanDyke\Config\Global.ini S:"SecureCRT Tab State"=1,1,1,0,0 S:"SecureFX Local Tab State"=1,-1,200 D:"Max Chat Window History"=000000c8 D:"Active Window Alpha Transparency"=000000f0 D:"Save Keymaps As Unicode"=00000000

神棍之路 3705

三相电机控制入门:端电压、相电压、线电压到底怎么测?(附实测波形对比)

本文为三相电机控制初学者提供了端电压、相电压和线电压的完整测量指南。通过厘清三者的物理定义与测量方法,详细讲解了如何搭建虚拟星形点电路,并对比分析了方波、SPWM和SVPWM三种主流控制模式下关键电压波形的核心特征与差异,帮助工程师掌握正确的示波器测量与波形解读技巧。

oauth7security的博客 648

使用yum安装MySQL5.7

前言 原文地址:https://www.cnblogs.com/brianzhu/p/8575243.html 正文 在CentOS7中默认安装有MariaDB,这个是MySQL的分支,但为了需要,还是要在系统中安装MySQL,而且安装完成之后可以直接覆盖掉MariaDB。 1. 下载并安装MySQL官方的Yum Repository [r...

姚句的博客 2万+

【速通RAG实战:索引】4.RAG文档解析技术

通过本文技术方案,可构建高精准、高效率的文档解析流水线,为 RAG 应用提供坚实的知识底座。核心在于**格式解析的鲁棒性**和**语义分块的准确性**,后续通过持续的性能优化和质量监控,逐步提升索引质量和检索效率。

2025博客之星Top81。专注AI工程化与架构实战。从分布式思维到模型部署,用工程化视角为你厘清AI落地的真实路径。 1544

CentOS7 Mysql 忘记密码或临时密码进不去时怎么跳过密码进去然后再更改密码

在[mysqld]下面加。

小方的博客 1332

Python 爬虫实战:深入闲鱼平台,抓取二手好物价格波动数据

本文介绍了如何利用Python爬虫抓取闲鱼(Xianyu)二手交易平台的商品价格数据并分析其波动趋势。通过requests和BeautifulSoup库实现网页数据抓取与解析,使用pandas进行数据清洗和存储,最后借助matplotlib可视化价格波动情况。文章详细展示了从网页结构分析、数据采集到波动率计算和趋势可视化的完整流程,并建议通过定时任务实现持续数据更新。该项目能为二手市场交易者提供价格参考,帮助优化买卖决策。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 3375

把复杂计算推到数据库里:ABAP CDS View Table Function 从原理到落地实践

摘要:本文深入解析ABAP CDS Table Function技术,重点探讨其在复杂业务场景下的应用价值。当CDS View无法满足窗口函数、递归计算等高级需求时,Table Function通过结合CDS类型系统与AMDP的数据库原生计算能力,成为关键解决方案。文章详细介绍了Table Function的架构设计(CDS实体声明+AMDP实现)、客户端处理机制、开发传输流程中的注意事项,并通过航班数据示例展示最小实现闭环。这项技术特别适用于需要将复杂计算下推到数据库层的场景,能显著提升RAP和OData

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 2291

CentOS 7安装 MySQL5.7之后,登录提示ERROR 1045 (28000): Access denied for user 'root'@'localhost'

1、安装完MySQL5.7之后,使用mysql -u root -p登录MySQL时报错: [root@localhost bin]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 2、百度搜了很多解决方法,都...

蓝天白云 3861

YOLOv11改进 - C3k2融合 | C3k2 融合 ARConv 自适应矩形卷积:动态调整卷积核形状与采样点

本文介绍了将自适应矩形卷积(ARConv)模块与YOLOv11相结合的方法。ARConv是针对遥感图像全色锐化任务设计的创新卷积模块,可自适应调整卷积核形状与采样点数量,解决传统卷积刚性限制,实现高效特征提取。其工作流程包括学习卷积核高度和宽度、选择采样点数量、生成采样图、卷积实现与空间自适应增强。我们将集成ARConv的C3k2_ARConv模块引入YOLOv11,对相关代码进行修改和注册,并配置了yolov11 - C3k2_ARConv.yaml文件。实验脚本显示,该结合方式应用于目标检测任务。

魔改工程师的博客 1005

CentOS 7安装 MySQL5.7之后,登录提示ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passw

1、安装完MySQL5.7之后,使用mysql -u root -p登录MySQL时报错: [root@localhost bin]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 2、百度搜了很多解决方法...

ckg8933的博客 3万+

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

解决MySQL5.7在MAC下登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

问题描述 今天在MAC上安装完MYSQL后,MYSQL默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决方案: 既然现在没法登录到数据库中,改密码和添加用户等操作也无从...

11月的淡然的博客 4767

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

centos7 上安装mysql5.7后登录报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pas

centos7 安装mysql5.7 1054问题

keepd的博客 4万+

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

mysql5.7 1045 linux_Linux mysql 5.7: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (...

环境:mac10.12使用root登录时遇到了ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)错误. 如下所示[root@DB-Server tmp]# rpm -ivh MySQL-server-5.6.19-1.rhel5.x86_64.rpmPreparing... ...

weixin_42223120的博客 278

Mysql5.7.21 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 解决

登陆mysql mysql -u root -p 出现错误,提示 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 密码错误。 我忘记密码了。下面就是如何重置密码  关闭mysql service mysqld stop 修改my.cnf配置文件 打开mysql配...

liu_shi_jun的专栏 1176

mysql5.7 1045 28000_解决MySQL5.7在MAC下登录ERROR 1045 (28000): Access denied for user 'root'@'localhost' (...

问题描述今天在MAC上安装完MYSQL后,MYSQL默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)解决方案:既然现在没法登录到数据库中,改密码和添加用户等操作也无从谈起。好在MySQL中...

weixin_39669982的博客 317

重置密码解决MySQL5.7 for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost'

一般这个错误是由密码错误引起,解决的办法自然就是重置密码。 假设我们使用的是root账户。 1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下: #vim /etc/my.cnf(注:windows下修改的是my.ini) 在文档内搜索mysqld定位到[mysqld]文本段: /mysqld(在vim编辑状态下直接输入该命令可搜索文本内容) 在[mysqld]后面任意一行添...

兵临城下的博客 3087

centos7 上安装mysql5.7后登录报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor...

原文转载自以下链接:https://blog.csdn.net/keepd/article/details/77151006 安装完mysql后会有个临时密码去日志查看,但是查看登录修改密后还是不行 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:yes) 于是...

auaya88442的博客 305

centos7 上安装mysql5.7后登录报错ERROR 1045 (28000): Access denied for user 'root'@'localhost'

安装完mysql后会有个临时密码去日志查看,但是查看登录修改密后还是不行 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:yes) 于是 1,停止mysql服务 systemctl stop mysqld.service     2,修改配置文件无密码登录   vi /...

CrazyAlisca的博客 634

解决centos7上安装mysql5.7后知道登录密码还报错ERROR 1045(28000): Access denied for user 'root'@'localhost'(using pas

解决centos7上安装mysql5.7后知道登录密码还报错ERROR 1045(28000): Access denied for user 'root'@'localhost'(using password: YSE)mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式可以找到root默认密码:shell>grep 'temp...

qq_36359009的博客 2877

Win10通过命令行窗口登录MySQL5.7时出现ERROR 1045 (28000): Access denied for user 'root'@'localhost'的解决办法

1、打开MySQL目录下的my.ini文件,在文件的最后添加一行“skip-grant-tables”,保存并关闭文件。(Win10默认安装,my.ini在C:\ProgramData\MySQL\MySQL Server 5.7。需要注意的是,"C:\ProgramData"为隐藏目录) 2、重启MySQL57和MySQL Router服务。 3、通过命令行窗口进入MySQL的bin目录...

babysuit影的博客 1838
上一篇: spark rdd
下一篇: 深入理解Java G1垃圾收集器
touch_future
博客等级 码龄10年 3粉丝 12原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值