mac安装mysql修改密码_mac下安装mysql忘记密码的修改方法

一、mac下安装mysql数据库

1.下载mysql数据库

下载地址:访问mysql的官网 ,进行下载。

进入mysql的下载界面()

下载x86,64bit的dmg文件:直接选择最下面的“no thanks,just take me to downloads!”

2.安装mysql数据库

打开mysql安装包后,点击安装主程序pkg文件。

3.启动mysql数据库

打开mysql数据库文件方式,在系统偏好设置中打开,点击mysql,start mysql server ,即可启动mysql。

4.终端登录mysql数据库:

mysql -u root -p

回车,默认密码为空。出现password后回车即可。

二、安装数据库后发现忘记了数据库密码

1.首先关闭mysql数据库

系统偏好设置中关闭mysql,stop mysql server

2.进入安全模式

? bin sudo su

password:

sorry, try again.

password:

sh-3.2# ./mysqld_safe --skip-grant-tables &

[1] 3477

sh-3.2# 2017-06-27t08:32:37.6nz mysqld_safe logging to '/usr/local/mysql-5.7.18-macos10.12-x86_64/data/localhost.err'.

2017-06-27t08:32:37.6nz mysqld_safe starting mysqld daemon with databases from /usr/local/mysql-5.7.18-macos10.12-x86_64/data

sh-3.2#

3.重新启动一个终端

~ mysql -u root -p

enter password:

welcome to the mysql monitor. commands end with ; or \g.

your mysql connection id is 16

server version: 5.7.18 mysql community server (gpl)

copyright (c) 2000, 2017, 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.

4.输入命令

mysql> flush privileges;

query ok, 0 rows affected (0.06 sec)

5.重新设置密码

mysql> set password for root@'localhost' = password('root');

query ok, 0 rows affected, 1 warning (0.02 sec)

6.再次输入命令

mysql> flush privileges;

query ok, 0 rows affected (0.00 sec)

以上所述是小编给大家介绍的mac下安装mysql忘记密码的修改方法,希望对大家有所帮助

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值