惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
V
V2EX
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
Martin Fowler
Martin Fowler
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
The Cloudflare Blog
T
Tailwind CSS Blog
H
Help Net Security
腾讯CDC
爱范儿
爱范儿
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
D
DataBreaches.Net
C
Check Point Blog
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com

博客园 - 特洛伊-Micro

Anatomy of a .PPTX File: Unpacking the Open XML Format fiddlerscriptCustomize Menus Fiddler And LINQ Fiddler 过滤 js、css、jpg 等请求 Linq 中 Join 的用法 Open in Windows Terminal as administrator .NET 内存碎片化分析 Android 常见脱壳与反编译工具 使用夜神模拟器调试安卓apk C#实现前向最大匹配、字典树(分词、检索) Task.Run vs Task.Factory.StartNew 时下最流行的5个用于桌面应用程序开发的 JS 框架介绍 What Is A Web Application Firewall? Ubuntu18.04 source.list更新国内源 ubuntu16.04 wordpress建站教程 Ubuntu1604 Install PHP 7.4 Inside the Storage Engine: Anatomy of a record Inside the Storage Engine: Anatomy of a page MSSQL forensics (1) - MDF fundamentals
ERROR 1045 (28000): Access denied for user 'root'...
特洛伊-Micro · 2022-12-05 · via 博客园 - 特洛伊-Micro

在Ubuntu下

想要登录mysql数据库

root@JD:~# mysql -uroot -p

报错

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

导致登录数据库不成功

打开文件

Ubuntu 14.04下apt-get安装mysql,登陆无法登陆,报错信息这样描述:在用命令(sudo apt-get install mysql-server mysql-client)安装完.mysql服务即开始运行了.此时需要修改root密码,但经常会出现这么一种情况.’Access denied for user ‘root’@’localhost’ (using password: YES)’ 或者其他致使无法登录mysql的情况。

解决方法:
1.打开/etc/mysql/debian.cnf文件,里面存储了相关的密码,我的文件信息如下

sudovi /etc/mysql/debian.cnf# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = 6x1XG2B5p75WtFV2
socket = /var/run/mysqld/mysqld.sock

[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = 6x1XG2B5p75WtFV2
socket = /var/run/mysqld/mysqld.sock
basedir = /usr

在[client]段有user=以及password=这两行,这就是通过apt-get安装mysql,系统给我们设置的mysql登录名和密码

输入命令:
mysql -u debian-sys-maint -p     

#debian-sys- maint即debian.cnf中user=后面的内容.回车后会提示输入密码,此时把password=后面的内容复制粘贴后回车即可进行mysql 控制台

 

use mysql;
update mysql.user set authentication_string=password('新密码') where user='root'and Host ='localhost';
update user set plugin="mysql_native_password"; 
flush privileges;
quit;
vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 英文输入环境下,敲 i 键,进入插入模式
#上下左右键移动光标,确保 bind-address = 127.0.0.1没有被注释掉
#英文输入环境下,敲Esc键,输入:wq 保存退出

回到 vim  /etc/mysql/mysql.conf.d/mysqld.cnf将刚才加入的那一行“skip-grant-tables”注释或删除掉。

再次重启mysql服务 service mysql restart,使用新的密码登陆,修改成功

mysql -u root -p 
#新密码
mysql>

问题解决