zoukankan      html  css  js  c++  java
  • Mac

    在什么情况下,需要重置root密码呢?那就是我们忘记了。还有一种比较坑的,那就是笔者的这种情况。按照正常的情况下,MySQL安装完之后,会弹出一个对话框,显示着一个临时的root密码,但无论笔者如何重装MySQL,始终不给我一个临时的root的密码,导致笔者一直无法登陆MySQL,没办法,只能用硬的,那就是重置密码。

    停止MySQL的服务,打开系统的偏好设置,找到MySQL 进去后,点击Stop MySQL Server即可。

    step1:
    苹果->系统偏好设置->最下边点mysql 在弹出页面中 关闭mysql服务(点击stop mysql server)
    step2:
    进入终端输入:cd /usr/local/mysql/bin/
    回车后 登录管理员权限 sudo su
    回车后输入以下命令来禁止mysql验证功能 ./mysqld_safe --skip-grant-tables &
    回车后mysql会自动重启(偏好设置中mysql的状态会变成running)

    开启两个终端,在第一个终端输入sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables,输入当前用户的密码:

    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

    那么就换下面这种:

    macdeMacBook-Pro:~ mac$ mysql -uroot -h127.0.0.1 -p
    Enter password: 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    然后在第二个终端输入sudo /usr/local/mysql/bin/mysql -u root,然后输入当前用户的密码后,出现以下的界面

    macdeMacBook-Pro:~ mac$ sudo /usr/local/mysql/bin/mysql -u root
    Password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 3
    Server version: 5.7.22 Homebrew
    
    Copyright (c) 2000, 2018, 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> 
    然后输入命令UPDATE mysql.user SET authentication_string=PASSWORD('新密码') WHERE User='root';回车,出现以下的界面,说明修改成功。
    mysql> UPDATE mysql.user SET authentication_string=PASSWORD('123456') WHERE User='root';
    Query OK, 1 row affected, 1 warning (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 1

     
    接下来输入FLUSH PRIVILEGES;回车,出现下面的界面
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.01 sec)

     
    最后,输入q,退出。关闭第一个终端,回到系统的偏好设置,重新开启MySQL即可。
    mysql> q
    Bye
    macdeMacBook-Pro:~ mac$ mysql -uroot -h127.0.0.1 -p
    Enter password: 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    macdeMacBook-Pro:~ mac$ sudo /usr/local/mysql/bin/mysql -u root
    Password:
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 3
    Server version: 5.7.22 Homebrew
    
    Copyright (c) 2000, 2018, 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> UPDATE mysql.user SET authentication_string=PASSWORD('123456') WHERE User='root';
    Query OK, 1 row affected, 1 warning (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 1
    
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> q
    Bye
    macdeMacBook-Pro:~ mac$ 
  • 相关阅读:
    2017年下半年软考合格标准出炉啦
    练网软考知识点整理-项目配置管理流程
    简练网软考知识点整理-项目招标投标中的法律责任
    简练网软考知识点整理-软件维护类型
    简练网软考知识点整理-软件质量保证及质量评价
    简练网软考知识点整理-项目配置管理配置审计
    简练网软考知识点整理-项目问题日志(Issue Log)
    简练网软考知识点整理-风险应对措施(应急计划、弹回计划和权变措施)
    简练网软考知识点整理-项目组织分解结构OBS
    简练网软考知识点整理-项目配置管理计划
  • 原文地址:https://www.cnblogs.com/gongyuhonglou/p/9020137.html
Copyright © 2011-2022 走看看