数据库登录报错信息:
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
解决数据库登录报错
在今天的MySQL数据库重置之后使用默认密码登录报错:

查看数据库的初始密码:

awk '/temporary password/' /var/log/mysqld.log //方法一grep 'temporary password' /var/log/mysqld.log    //方法二
[root@localhost ~]#  awk '/temporary password/' /var/log/mysqld.log  //此命令可以查看初始数据库密码
2022-05-11T22:16:55.167414Z 1 [Note] A temporary password is generated for root@localhost: wtCqfv!1hZ2u[root@localhost ~]# mysql -uroot -pwtCqfv!1hZ2u //登录到MySQL数据库时候报错了
mysql -uroot -pwtCqfvsetenforce 0hZ2u
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

报错信息为:

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解决方法一为将一条命令改换为两行命令执行

[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.38Copyright (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>
Query OK, 0 rows affected (0.00 sec)

初始化登录成功后即可修改密码:

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

解决方法二开启symbolic-links=0 跳过密码登录到数据库

[root@node3 ~]# vim /etc/my.cnf
[mysqld]
symbolic-links=0

重启数据库

[root@node3 ~]# systemctl restart mysqld

再次输入登录到MySQL的命令,执行按回车即可进入数据库

[root@node3 ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.38 MySQL Community Server (GPL)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>

登录数据库后即可进行修改密码
如在修改密码时有保错信息

mysql> alter user root@localhost identified by '123456';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this 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

使用flush privileges; 再次修改命令即可

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

解决MySQL数据库登录报错原因以及修改MySQL数据库登录密码;相关推荐

  1. 报错解决:加载数据库驱动报错-Loading class `com.mysql.jdbc.Driver‘. The new driver class is `com.mysql.cj.jdb

    Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.D ...

  2. mysql从节点报错_CentOS7.9 下 MySQL 之 PXC 集群部署【Docker+多机多节点】

    背景 最近在进行 MySQL 集群搭建测试的研究中 对于业界主流方案自然不能跳过 在此,整理成完整的文章,希望道友能得到参考价值 - [注]:Percona XtraDB Cluster(简称 PXC ...

  3. git登录报错,git clone无法记住用户名密码,修改git提交用户名

    目录 git登录报错 git无法记住用户名密码 修改git提交用户名 git登录报错 报错如下: 这种问题可能是因为你使用的电脑是之前别人用过的,git的用户信息存储的还是之前登录人的账户密码,所以导 ...

  4. mysql 唯一性约束报错_怪异的MySQL Online DDL报错Duplicate entry

    今天线上执行Online DDL的时候发现一个奇怪的报错,觉得比较意义,遂整理如下.线上数据库版本:percona server 5.7.14 报错现场:每次执行的时候重复报错记录都不一样 mysql ...

  5. oracle管理员登录报错,关于Oracle使用管理员账号登录失败的问题

    我在本地建的Oracle数据库在调试自己写的存储过程的时候提示缺少 debug connect session 权限,一般情况下根据这个提示直接用管理员账号登录进去,执行 grant debug co ...

  6. centos安装mysql(证书报错处理+navicat连接centos数据库)

    centos7安装musql57 1.下载 MySQL Yum Repository wget http://dev.mysql.com/get/mysql57-community-release-e ...

  7. 【庖丁解牛】Navicat for MySQL连接时候报错1251无法连接MySQL

    问题重现: 已经安装好MySQL并设置本地用户可以登录MySQL,下载并安装navicat后,进行安装测试,结果提示1251错误,无法继续链接. 问题解决 先在CMD里启动数据库,然后登录数据库进行修 ...

  8. mysql插入blob报错_java如何向mysql写入blob数据?

    表结构如下 package entity; import java.io.Serializable; public class Person implements Serializable{ priv ...

  9. mysql批量添加报错_技术分享 | MySQL 在批量插入时捕捉错误信息

    原创: 杨涛涛 背景 本篇文章来源于今天客户问的一个问题. 问题大概意思是:我正在从 Oracle 迁移到 MySQL,数据已经转换为单纯的 INSERT 语句.由于语句很多,每次导入的时候不知道怎么 ...

  10. win10安装MySQL数据库和MyServer数据库及其报错记录

    锚点: Win10装MySQL数据库及报错记录 Win10装MySever数据库及报错记录 <----------------分 隔 符----------------> Win10装My ...

最新文章

  1. 8道Python基础面试练习题
  2. 【深度学习】对抗扰动、垃圾/钓鱼邮件自动分类和UEBA
  3. 添加Mysql普通用户来管理hive
  4. SetInterval和SettimeOut(转载文章)
  5. 20210808 滑模中常见趋近率
  6. 与众不同 windows phone (15) - Media(媒体)之后台播放音频
  7. 如何为部署到 SAP BTP 平台上的 Node.js 应用提供Authorization 和 Trust 管理 - 权限管控
  8. CMD各段定义与分配方法指引
  9. python open permission denied_python - Image.open PermissionError:[Errno 13]权限被拒绝: - 堆栈内存溢出...
  10. 【LeetCode笔记】139. 单词拆分(Java、动态规划、字符串、哈希表)
  11. c语言交通违章编程代码,C语言程序设计之交通处罚单管理系统 报告(内含代码).doc...
  12. 锐捷客户端显示无法连接认证服务器,锐捷客户端连接失败怎么办 锐捷连不上解决办法...
  13. 信号与线性系统管致中第六版pdf_【对讲机的那点事】无线电天馈系统中载频合路器的作用...
  14. 在xilinx SDK中查询API函数的方法
  15. 网吧显示最近使用计算机,影子系统怎么用?实现像网吧电脑一样重启后自动还原系统教程...
  16. tomcat系列之项目下载中文文件乱码问题
  17. 博科光纤交换机IP+端口策略应用
  18. 37 一次获取redis连接阻塞引起的 Thread pool is EXHAUSTED
  19. 《30天自制操作系统》学习笔记--第0天
  20. IDEA你可能不知道的小工具

热门文章

  1. wim工具扫描linux磁盘,install.wim怎么提取 install.wim文件在哪里
  2. 08#wordcloud2包 词云生成器
  3. MVP是什么,不是什么
  4. wifi mouse linux,WiFi Mouse Pro
  5. 怎么关闭火狐浏览器的百度辅助模式(无障碍服务)
  6. duet太香啦啦啦啦啦啦啦啦啦啦
  7. 三级等保 关闭111端口
  8. Android方向传感器
  9. 九八寒露——HRBUST OJ 1269 小把戏
  10. python修改文件内容_Python之文件处理-批量修改md文档内容-Go语言中文社区