• connect to database error : Access denied for user 'root'@'localhost'


    参考链接: https://www.cnblogs.com/JadenFK3326/p/Ubuntu.html

    连接到数据库时,提示如下错误:

     connect to database error : Access denied for user 'root'@'localhost'

    解决方法如下:

    1、 用管理员密码登录  mysql -udebian-sys-maint -p

       管理员密码存储位置:/etc/mysql

       hbg@rohens:/etc/mysql$ sudo cat debian.cnf
    [sudo] hbg 的密码:
    # Automatically generated for Debian scripts. DO NOT TOUCH!
    [client]
    host     = localhost
    user     = debian-sys-maint
    password = 5Em08U7izRDbYa5J
    socket   = /var/run/mysqld/mysqld.sock
    [mysql_upgrade]
    host     = localhost
    user     = debian-sys-maint
    password = 5Em08U7izRDbYa5J
    socket   = /var/run/mysqld/mysqld.sock

    2、修改密码

      use mysql

      update mysql.user set authentication_string=password('新密码') where user='root' and Host ='localhost';

      update user set plugin="mysql_native_password";

      flush privileges;

      quit;

    3、重启mysql

           service mysql restart

        

  • 相关阅读:
    大数据的起步:初学者
    接触区块链
    学习开始了,博客开始了
    hadoop分布式的搭建过程
    Java笔试题
    JavaSCript全局变量与局部变量
    OSGI
    restful
    jersey
    JSP+Servlet+Mybits小例子
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/13692888.html
Copyright © 2020-2023  润新知