mysql本地安装后总是提示密码错误

当安装MySQL后遇到无法使用默认密码登录的问题,可以通过编辑`my.cnf`文件,添加`skip-grant-tables`跳过密码验证,然后重置root密码。在设置新密码后,注释掉`skip-grant-tables`,重启MySQL服务即可恢复正常。这是一个解决ERROR 1045 (28000)问题的具体步骤。
摘要由CSDN通过智能技术生成

重置密码遇到ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwor:yes)问题

 

及时你安装后记下了它给分配的默认密码,以后开启mysql后要输入的密码,还是有问题,对于这种情况需要具体问题具体分析。

我安装的是mysql-5.7.22-macos10.13-x86_64.dmg 

从网上找的,走官网也比较麻烦,网速慢,可能还没有你想要的版本,这个需要和你的本地macos版本匹配才行。

1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下:

#vim /etc/my.cnf

如果没有这个文件,及自己创建出来,

# Example MySQL config file for medium systems.  
  #  
  # This is for a system with little memory (32M - 64M) where MySQL plays  
  # an important part, or systems up to 128M where MySQL is used together with  
  # other programs (such as a web server)  
  #  
  # MySQL programs look for option files in a set of  
  # locations which depend on the deployment platform.  
  # You can copy this option file to one of those  
  # locations. For information about these locations, see:  
  # http://dev.mysql.com/doc/mysql/en/option-files.html  
  #  
  # In this file, you can use all long options that a program supports.  
  # If you want to know which options a program supports, run the program  
  # with the "--help" option.  
  # The following options will be passed to all MySQL clients  
  [client]
  default-character-set=utf8
  #password   =  uhB9p.Xwup>e
  port        = 3306  
  socket      = /tmp/mysql.sock   
  # Here follows entries for some specific programs  
  # The MySQL server  
  [mysqld]
  skip-grant-tables
  character-set-server=utf8
  init_connect='SET NAMES utf8
  port        = 3306  

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值