mac上mysql忘记密码怎么解决?


本文摘自PHP中文网,作者青灯夜游,侵删。

解决方法:首先打开终端,输入命令“mysql -u root”;然后输入命令“UPDATE mysql.user SET authentication_string=PASSWORD('新密码') WHERE User='root';”。

(推荐教程:mysql视频教程)

mac 中登陆mysql忘记密码解决办法

1、打开终端,输入命令:cd /usr/local/mysql/bin

2、mysql -uroot -p,用这条命令登陆时报错信息:

报错:

1

2

Enter password:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

3、打开终端输入:sudo mysqld_safe --skip-grant-tables

输出

1

2

Password:

Logging to '/usr/local/mysql/data/localhost.err'.2018-10-10T03:21:40.6NZ mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data

4、打开一个新的终端,输入:mysql -u root ,会看到以下输出。

1

2

3

4

5

6

7

8

9

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 16Server version: 5.7.23 MySQL Community Server (GPL)

 

Copyright (c) 2000, 2018, 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 respective

owners.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

mysql>

5、终端输入 use mysql显示如下

1

2

3

4

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

6、修改密码:UPDATE mysql.user SET authentication_string=PASSWORD('你的密码') WHERE User='root';

1

2

Query OK, 1 row affected, 1 warning (0.01 sec)

Rows matched: 1 Changed: 1 Warnings: 1

相关推荐:php培训

以上就是mac上mysql忘记密码怎么解决?的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

如何查看mysql的日志文件

mysql 常用数据库语句 小练习

mysql 清除表空间碎片的实例详解

php程序mysql报错mysql has gone away

mysql怎么导入excel数据?

mysql中where与on的区别及何时使用详析

在同一台机器上运行多个 mysql 服务

介绍mysql和jdbc的事务控制(tcl)

如何从完整的mysql db转储文件中提取表备份

mysql中group by用法是什么

更多相关阅读请进入《Mac》频道 >>


数据库系统概念 第6版
书籍

数据库系统概念 第6版

机械工业出版社

本书主要讲述了数据模型、基于对象的数据库和XML、数据存储和查询、事务管理、体系结构等方面的内容。



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...