Mac下修改Mysql初始密码

1.很不幸,新装的mysql,弹窗的时候习惯性关了。。。于是只能苦逼去官网找修改密码的办法。

官网地址:https://dev.mysql.com/doc/refman/5.7/en/resetting-permissions.html(第三个方法)

Step1.

Stop the MySQL server if necessary, then restart it with                the--skip-grant-tablesoption. This enables anyone to connect without a                password and with all privileges, and disables                account-management statements such asALTER USERandSET PASSWORD. Because                this is insecure, you might want to use--skip-grant-tablesin                conjunction with--skip-networkingto                prevent remote clients from connecting.

在系统偏好设置最下面关闭mysql,

root权限下进入/usr/local/mysql/bin目录下,

执行 ./mysqld_safe --skip-grant-tables &

这时候mysql就会重启,你在系统偏好设置那也能看到mysql是running状态。


Step2.

输入./mysql

输入命令 FLUSH PRIVILEGES

输入命令 SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你的新密码')

密码就设置成功了。


Step3.

杀死mysql,然后重启mysql。


PS:下面是我输入的命令行:

renheMacdeiMac:~ renhemac$ sudo su -

renheMacdeiMac:~ root# cd /usr/local/mysql/bin/

renheMacdeiMac:bin root# ./mysqld_safe --skip-grant-tables &

./mysql

mysql> FLUSH PRIVILEGES;

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('123456');

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容