当前位置: 移动技术网 > IT编程>数据库>Mysql > mac下安装mysql忘记密码的修改方法

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

2017年12月07日  | 移动技术网IT编程  | 我要评论

春日登楼怀归,缠足图片,2岁宝宝食谱

一、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忘记密码的修改方法,希望对大家有所帮助

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网