首页 > 数据库 >安装mysql报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES,并设置密码登录

安装mysql报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES,并设置密码登录

时间:2023-12-04 14:24:11浏览次数:1039  
标签:log 1045 mysqld mysql var 报错 root

@

目录

当前状态

目前已经启动好mysql服务:

systemctl start mysqld

systemctl status mysqld

image

生成临时密码

grep 'temporary password' /var/log/mysqld.log 

报错

出现了报错:

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

image

解决办法:

修改 /etc/my.cnf文件,在最后加入skip-grant-tables


# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# 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

skip-grant-tables

实现无密码登录
image

最后,刷新权限,修改root密码

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)

就可以使用密码登录了
image

标签:log,1045,mysqld,mysql,var,报错,root
From: https://www.cnblogs.com/young2635/p/17874794.html

相关文章

  • Jdk升级到1.7后,hutool工具类的很多方法报错解决方案
    报错如下:java.lang.reflect.InaccessibleObjectException:Unabletomakefieldprivatefinaljava.util.Mapsun.reflect.annotation.AnnotationInvocationHandler.memberValuesaccessible:modulejava.basedoesnot"openssun.reflect.annotation"tounnamed......
  • Qt程序运行报错
    报错内容PC环境为Ubuntu20.04,Qt版本是Qt5.12.9,AsensingViewer是编译好的程序./AsensingViewer:errorwhileloadingsharedlibraries:libicudata.so.56:cannotopensharedobjectfile:Nosuchfileordirectory问题分析查看程序依赖lddAsensingViewer注意到有个库......
  • 记Redux下载后,运行examples/todos时,报错Error: error:0308010C:digital envelope rout
    1、Redux下载下载地址gitclonehttps://github.com/reactjs/redux.git进入examples/todos,下载依赖:npminstall2、问题复现及解决执行命令npmrunstart此时终端报错:Error:error:0308010C:digitalenveloperoutines::unsupported解决方法:打开package.json,修改......
  • python报错:Pip 20.3+ break proxy connection
    参考:https://www.cnblogs.com/devilmaycry812839668/p/17872452.html   ==================================== 在proxy方式下使用pip有时候会报错。原因是某些版本pip依赖的urllib3库默认使用https方式进行网络连接,但是在proxy模式下由于大部分的proxy工具都是不支持h......
  • CentOS6.10运行KVM,报错【合集】
    实验环境服务器CentOS6.10;安装虚拟机个数3个,操作系统CentOS7.9如下图所示:Unabletoopenaconnectiontothelibvirtmanagementdaemon.查看报错,发现libvirt服务已经启动了,那么使用root权限,重新启动libvirt即可,sudoservicelibvirtdrestart......
  • matplotlib报错:AttributeError: module 'backend_interagg' has no attribute 'Figure
    使用本地python环境可以成功执行importpandasaspdimportmatplotlib.pyplotasplt#设置字体plt.rcParams['font.sans-serif']=['SimHei']#能正确显示负号plt.rcParams['axes.unicode_minus']=False#设置画布大小plt.figure(figsize=(11,8))#柱状图pat......
  • 连接huggingface.co报错:(MaxRetryError("SOCKSHTTPSConnectionPool(host='huggingface
    参考:https://blog.csdn.net/shizheng_Li/article/details/132942548https://blog.csdn.net/weixin_42209440/article/details/129999962  ============================  随着国际顶级的AI公司广泛使用huggingface.co,现在的huggingface.co已经成了搞AI的不可或缺的一......
  • hive升级元数据报错The reference to entity "useSSL" must end with the ';' delimit
    使用Hive自带的schematool工具升级元数据,也就是把最新的元数据重新写入MySQL数据库中。执行以下命令cd/usr/local/hive./bin/schematool-initSchema-dbTypemysql出现Thereferencetoentity"useSSL"mustendwiththe';'delimiter.修改之前配置的hive-site.xml原......
  • 苹果iPhone因没有存储空间而死机和不断重启,重启白苹果黑底,恢复模式更新系统报错1110,解
    参考自:https://www.bilibili.com/video/BV1Mr4y1X7cT/?spm_id_from=333.337.search-card.all.click&vd_source=869b36c3961d4a89a184a469bc7589bb手机苹果iPhone,存储满,提示重启后白苹果,无法进入系统。操作方法:1、mac雷电接手机后,进入DFU,短按一下音量加键并松开,立刻再短按音量减......
  • tp6 composer安装workerman报错
    命令:composerrequiretopthink/think-worker错误信息:Problem1-Rootcomposer.jsonrequirestopthink/think-worker^4.0->satisfiablebytopthink/think-worker[v4.0.0].-topthink/think-workerv4.0.0requirestopthink/framework^8.0->foundtopth......