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中的特性,安装过程中没有设置密码的环节,在网络上找了半天,总算解决了!特此记录下来,以便以后查 ...
随机推荐
- RMAN:简单的duplicate创建新数据库
duplicate to "test" backup location '/home/oracle/11.2.0.4/assistants/dbca/templates/'; du ...
- redis 的set数据类型
相关命令 1.SADD SADD key-name item1 [item 2…] 将一个或多个成员元素加入到集合中 2.SREM SMEMBERS key-name item1 [item 2…] ...
- mysql初始化时报错bin/mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory的处理
问题描述: 今天新安装了一个linux虚拟机,然后安装mysql 5.7.21,在进行初始化的时候,报错 bin/mysqld: error : cannot open shared object f ...
- [Module] 03 - Software Design and Architecture
本篇涉及内容: ORM框架(无需再用contentprovider或者sqlitedatebasehelper之类的古董工具了) 规划各种业务Bean文件(配合ORM框架) 设计一个好的请求基类(Ba ...
- Android 4.0以上BlurMaskFilter效果无效
Android MaskFilter的基本使用: MaskFilter类可以为Paint分配边缘效果. 对MaskFilter的扩展可以对一个Paint边缘的alpha通道应用转换.An ...
- Eclipse------maven使用Maven build编译web项目显示" javax.servlet.http 不存在"
缺少javax.servlet包 解决方法: 引入下面代码即可 <project> <dependencies> <dependency> <groupId& ...
- 给树莓派安装看门狗的两种方法,二代B
树莓派的CPU是保护有硬件看门狗的,可以通过安装模块和值守程序来实现看门狗防止树莓派死机. 安装方法一:watchdog.sh的源码: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ...
- linux-友好显示文件大小
4850905319b / 1024 /1024/1024 = 4.6G ls -lh
- Memcached 数据导出与导入
我们使用 memcached-tool 命令来导出数据: [root@localhost ~]# memcached-tool dump > /tmp/.txt Dumping memcache ...
- Python进阶 学习笔记(三)
(涉及内容:定制类) __str__和__repr__ 如果要把一个类的实例变成 str,就需要实现特殊方法__str__(): class Person(object): def __init__( ...