600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > mac下如何安装mysql以及忘记密码如何重置密码

mac下如何安装mysql以及忘记密码如何重置密码

时间:2019-02-14 08:05:51

相关推荐

mac下如何安装mysql以及忘记密码如何重置密码

1. 下载mysql for mac:/downloads/installer/

2. 双击mysql-5.7.17-macos10.12-x86_64.dmg进行解压, 双击mysql-5.7.17-macos10.12-x86_64.pkg进行安装

3.Continue -> Continue, Agree -> Install -> 输入管理员密码

4. 记录下来弹窗中的密码

5. 进入系统偏好设置, 找到mysql, 启动服务

6. 将mysql的命令添加到系统中

(1).进入/usr/local/mysql/bin,查看此目录下是否有mysql

(2).执行vim ~/.bash_profile

在该文件中添加mysql/bin的目录

PATH=$PATH:/usr/local/mysql/bin

添加完成后,按esc,然后输入wq保存。

(3).最后在命令行输入source ~/.bash_profile

7. 通过mysql -uroot -p登录mysql, 输入之前保存的密码

8. 重置mysql初始密码

二:如果忘记截图中的密码

一、第一步:停止MySQL服务。

可能在使用MySQLWorkBench之前,你就开启了MySQL服务,所以这里需要关闭MySQL服务。

关闭MySQL服务的操作:

苹果->系统偏好设置->最下边点MySQL 在弹出页面中关闭mysql服务(点击stop mysql server

二、第二步:进入终端,指令重启MySQL服务。

0、打开终端:

1、输入指令1:(进入到mysql的bin目录下)

输入:cd /usr/local/mysql/bin/

2、输入指令2:

输入:sudo ./mysqld_safe --skip-grant-tables

3、输入指令2,会提示输入密码:(Mac账户的root用户密码)

4、输入密码后:会出现一堆提示:

Logging to '/usr/local/mysql-5.7.18-macos10.12-x86_64/data/ShiXiongweideMacBook-Pro.local.err'.-06-17T06:35:38.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.7.18-macos10.12-x86_64/data12

5、然后会发现,MySQL会自动重启。

附:第二步步骤,我这边终端上指令代码,罗列如下:

ShiXiongweideMacBook-Pro:~ shixiongwei$ cd /usr/local/mysql/bin/ShiXiongweideMacBook-Pro:bin shixiongwei$ sudo ./mysqld_safe --skip-grant-tablesPassword:Logging to '/usr/local/mysql-5.7.18-macos10.12-x86_64/data/ShiXiongweideMacBook-Pro.local.err'.-06-17T06:35:38.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql-5.7.18-macos10.12-x86_64/data123456

第三步:另外开一个终端,设置MySQL密码。

0、另外再开一个终端:

1、输入指令1:(进入到mysql的bin目录下)

输入:cd /usr/local/mysql/bin/

2、输入指令2:

输入:./mysql

3、进入到mysql命令状态下:(mysql>是mysql命令状态提示)

输入:mysql>FLUSH PRIVILEGES;

4、设置密码admin123

输入:mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('admin123');

附:第三步步骤,我这边终端上指令代码,罗列如下:

ShiXiongweideMacBook-Pro:~ shixiongwei$ cd /usr/local/mysql/bin/ShiXiongweideMacBook-Pro:bin shixiongwei$ ./mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 34Server version: 5.7.18 MySQL Community Server (GPL)Copyright (c) 2000, , Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.01 sec)mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('admin123');Query OK, 0 rows affected, 1 warning (0.00 sec)mysql>1234567891011121314151617181922

至此,MySQL初始密码就设置好了。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。