zoukankan      html  css  js  c++  java
  • 解决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)

    一般是密码错误引起,解决的办法是重置密码,  重置密码的第一步就是跳过MySQL的密码认证过程

    查找my.cnf文件的位置

    find / -name my.cnf

    我的文件位置是 ./etc/my.cnf,   打开my.cnf文件

    vim /etc/my.cnf

    找到[mysqld],在它的后面任意下一行添加如下代码

    skip-grant-tables

    然后重启mysql:

    systemctl stop mysqld.service
    systemctl start mysqld.service

    输入mysql

    用sql来修改root的密码 

    在mysql数据库有一个user表,存储的是数据库用户的信息,我们需要修改的里面用户的密码;

    show databases;

    命令依次为:

    1.use mysql;(使用mysql数据库)
    2.update user set password=password("你的密码") where user="root";     //mysql5.7版本下没有password 改成update user set authentication_string=password("你的密码") where user="root";
    3.flush privileges; 
    4.quit

    root账户就已经重置成新的密码了

    编辑my.cnf,去掉刚才添加的内容,然后重启MySQL

  • 相关阅读:
    keepass
    gpg
    Wireshark实践
    ssh
    namp
    第十二周
    第十一周
    第十周总结
    第九周学习总结
    编程语言
  • 原文地址:https://www.cnblogs.com/chong-zuo3322/p/13603154.html
Copyright © 2011-2022 走看看