Mac - MySQL初始密码忘记重置MySQL root密码
在什么情况下,需要重置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 (): Access denied for user 'root'@'localhost' (using password: NO)
那么就换下面这种:
macdeMacBook-Pro:~ mac$ mysql -uroot -h127.0.0. -p
Enter password:
ERROR (): 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
Server version: 5.7. Homebrew Copyright (c) , , 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('') WHERE User='root';
Query OK, row affected, warning (0.00 sec)
Rows matched: Changed: Warnings:
接下来输入FLUSH PRIVILEGES;回车,出现下面的界面
mysql> FLUSH PRIVILEGES;
Query OK, rows affected (0.01 sec)
最后,输入\q,退出。关闭第一个终端,回到系统的偏好设置,重新开启MySQL即可。
mysql> \q
Bye
macdeMacBook-Pro:~ mac$ mysql -uroot -h127.0.0. -p
Enter password:
ERROR (): 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
Server version: 5.7. Homebrew Copyright (c) , , 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';
Query OK, row affected, warning (0.00 sec)
Rows matched: Changed: Warnings: mysql> FLUSH PRIVILEGES;
Query OK, rows affected (0.01 sec) mysql> \q
Bye
macdeMacBook-Pro:~ mac$
Mac - MySQL初始密码忘记重置MySQL root密码的更多相关文章
- mysql忘记密码如何重置密码,以及修改root密码的三种方法
1.先将MySQL停止. 命令:systemctl stop mysqld #停掉MySQL 命令:systemctl status mysqld #查看状态 2.然后跳 ...
- [转帖]忘记了MariaDB root密码的解决办法
忘记了MariaDB root密码的解决办法 https://www.cnblogs.com/liaojie970/p/6126322.html 貌似跟 mysql 是一样的. 1.停掉mariaDB ...
- [转帖]Ubuntu忘记超级用户root密码,重新设置密码
Ubuntu忘记超级用户root密码,重新设置密码 版权声明:本文为博主原创文章,转载必须指明出处. https://blog.csdn.net/weixin_37909391/article/det ...
- Linux(Unix)密码策略问题导致root密码不能修改
Linux(Unix)密码策略问题导致root密码不能修改 发布时间: 2016-01-19 浏览次数: 1034 下载次数: 5 用户修改了密码配置文件,导致root账户修改密码时报如下错误: ...
- mysql root密码忘记重置及相关注意事项
1.使用mysqld_safe --skip-grant-tables跳过授权,进入mysql操作界面或者在配置文件mysqld 添加skip-grant-tables也行,找回后需要删除..恢复原样 ...
- Mysql(Linux服务器)root用户密码忘记重置方法
MySQL是非常常见的开源数据库,使用者众多,若是不小心忘记了安装在服务器的mysql密码,无法登陆,应该如何重置呢?方法很简单,现在和大家分享下.(系统环境:CentOs 6.5 软件:Mysql ...
- MySQL忘记密码,或:root密码重置报错:mysqladmin: connect to server at 'localhost' failed的解决方案
MySQL root密码重置报错:mysqladmin: connect to server at 'localhost' failed的解决方案 1 登陆失败,mysqladmin修改密码失败 ...
- mysql root密码忘记重置
1.修改/etc/my.cnf文件 找到mysqld选项,增加子项skip-grant-tables 2.重新启动mysql服务 service mysqld restart 3.进入mysql 在s ...
- 在Ubuntu 18.04 下安装mysql,没有初始密码,重设root密码
在Ubuntu 18.04 下安装mysql 不知道是由于mysql更新为新版还是.Ubuntu18.04中的特性,安装过程中没有设置密码的环节,在网络上找了半天,总算解决了!特此记录下来,以便以后查 ...
随机推荐
- Global.asax的Application_BeginRequest实现url重写无后缀的代码
本文为大家详细介绍下利用Global.asax的Application_BeginRequest 实现url重写其无后缀,具体核心代码如下,有需求的朋友可以参考下,希望对大家有所帮助 利用Global ...
- ESPCN处理彩色图像代码
原来仅处理了Y通道,输出的灰度图像. Super-Resolution/ESPCN at master · wangxuewen99/Super-Resolution · GitHub https:/ ...
- oracle 产生随机数
-- 产生一个任意大小的随机数select dbms_random.random from dual; -- 产生一个100以内的随机数select abs(mod(dbms_random.rando ...
- Python多线程运行带多个参数的函数
在python中经常会到用多线程处理某个函数来缩短运行时间. from multiprocessing import Pool def work(x): return x+1 pool = Pool( ...
- chrome插件开发之调试
https://blog.csdn.net/qustdong/article/details/46046553
- 1、一、Introduction(入门): 0、Introduction to Android(引进到Android)
一.Introduction(入门) 0.Introduction to Android(引进到Android) Android provides a rich application framewo ...
- 常用CSS备忘
1 怎样让div中的img居中 水平居中:div设置:text-align:center; img设置:width:图片宽度; margin:0 auto; 垂直居中:div设置:position:r ...
- POJ1159——Palindrome
Palindrome Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 53647 Accepted: 18522 Desc ...
- MyBatis入门程序之Mapper代理方式
Mapper代理的开发方式,程序员只需要编写mapper接口(相当于dao接口)即可,MyBatis会自动为mapper接口生成动态代理实现类. 一.开发规范 1.mapper接口的全限定名要和map ...
- 【docker】 centos7 安装docker
1.Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 通过 uname -r 命令查看你当前的内核版本 unam ...