zoukankan      html  css  js  c++  java
  • ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

      在安装好的MySQL服务器上,配置了环境变量之后,发现用mysql无法登录,报如题的错误,实在没有办法,决定用安全模式对root用户修改密码:

      首先关闭正在运行的MySQL;

      在一个终端窗口运行命令:mysqld_safe --user=mysql --skip-grant-tables --skip-networking&

    [root@MySQL ~]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking&

      运行之后新打开一个终端窗口:

    [root@MySQL ~]# mysql -u root mysql
    mysql> update mysql.user set authentication_string=password('mysql') where user = 'root'; Query OK, 1 row affected, 1 warning (0.02 sec) Rows matched: 1 Changed: 1 Warnings: 1 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> exit Bye

      以上是5.7版本的修改密码方式,在5.7中存储密码的字段不再是password了,变成了authentication_string,在5.7之前采用以下命令:

    mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';

      修改之后登陆成功:

    [root@MySQL ~]# mysql -uroot -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 6
    Server version: 5.7.9-log MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> 
  • 相关阅读:
    Ext JS 6开发实例(三) :主界面设计
    Ext JS 6开发实例(二) :使用CMD创建应用程序
    文件夹或者文件比对工具 Beyond Compare
    LIS问题(DP解法)---poj1631(模板)
    hdoj Max Sum Plus Plus(DP)
    A* 算法详解
    hdoj1043 Eight(逆向BFS+打表+康拓展开)
    hdoj2612 Find a way (bfs)
    luoguP3366 [模板] 最小生成树
    luoguP1196(带权并查集)
  • 原文地址:https://www.cnblogs.com/zx3212/p/6204563.html
Copyright © 2011-2022 走看看