zoukankan      html  css  js  c++  java
  • Mysql相关问题-----1045 Access denied for user 'root'@'localhost' (using password: YES)报错

    MySQL 连接错误,使用Navicat连接MySQL出现错误:1045 Access denied for user 'root'@'localhost' (using password: YES)

    解决方案:

    1.编辑mysql配置文件my.ini

    在mysql的安装目录下

    ,在[mysqld]这个条目下加入 skip-grant-tables 保存退出后重启mysql

    [mysqld]
    #作用是跳过登录的验证
    #skip-grant-tables
    port = 3306
    basedir=C:\softwaretool\mysql-5.7.23-winx64
    datadir=C:\softwaretool\mysql-5.7.23-winx64\data 
    max_connections=200
    character-set-server=utf8
    default-storage-engine=INNODB
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    max_allowed_packet = 20M
    [mysql]
    default-character-set=utf8

    2.重启mysql

    在计算机-管理-服务里面找到MySQL的服务,如图

    这时候在cmd里面输入mysql -u root -p就可以不用密码登录了,出现 password:的时候直接回车可以进入,不会出现ERROR 1045 (28000),但很多操作都会受限制,因为没有grant权限。

    3.进入mysql数据库,给root用户设置密码

    mysql> use mysql; 
    mysql> update mysql.user set authentication_string=password('密码') where user='root' ;

    4.刷新数据库,并退出

    mysql> flush privileges;
    mysql> quit; 

    5.修改my.ini文件

    改好之后,再修改一下my.ini这个文件,把我们刚才加入的 "skip-grant-tables"这行删除,保存退出再重启mysql服务,再重新用Navicat连接就可以了。

    [mysqld]
    #作用是跳过登录的验证
    #skip-grant-tables
    port = 3306
    basedir=C:\softwaretool\mysql-5.7.23-winx64
    datadir=C:\softwaretool\mysql-5.7.23-winx64\data 
    max_connections=200
    character-set-server=utf8
    default-storage-engine=INNODB
    sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
    max_allowed_packet = 20M
    [mysql]
    default-character-set=utf8

  • 相关阅读:
    禅道 之 项目开发必备
    Cmd 命令大全
    Php 性能参数优化 及 Iptables 防火墙限制用户访问平率
    Nginx 性能参数优化
    Mysql 性能调优参数
    Postfix的工作原理
    python三次输入错误验证登录
    python shopping incomplete code
    MySQL + Atlas --- 部署读写分离
    网站流量分析项目day03
  • 原文地址:https://www.cnblogs.com/luckyplj/p/11972143.html
Copyright © 2011-2022 走看看