如何在Mac OS 10.13.3中重置我的mysql密码 [英] how to reset my mysql password in mac os 10.13.3

查看:98
本文介绍了如何在Mac OS 10.13.3中重置我的mysql密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对MySQL有问题.我忘记了安装密码 因此,我现在无法访问服务器. 我尝试删除MySQL并重新安装,但没有再次显示密码. 所以我试图在终端上做到这一点,这就是结果... 首先,我停止了MySQL服务器

I have a problem with MySQL. I forgot the password I used when I installed it so, I can not access to the server now. I tried deleting the MySQL and install it again but it didn't show the password again. So I tried to do it by the terminal and this is the result ... first i stopped the MySQL server

然后我将sudo /usr/local/mysql/bin/mysqld_safe –skip-grant-tables放入终端

在那之后,我在新的终端窗口中写了sudo /usr/local/mysql/bin/mysql -u root UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root'; FLUSH PRIVILEGES; \q

after that in new terminal window i wrote sudo /usr/local/mysql/bin/mysql -u root UPDATE mysql.user SET Password=PASSWORD('root') WHERE User='root'; FLUSH PRIVILEGES; \q

结果是"ERROR 2002(HY000):无法通过套接字'/tmp/mysql.sock'(2)连接到本地MySQL服务器"

the result was "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"

所有这些命令

推荐答案

您可以尝试通过在安全模式下运行MySQL来重置根密码.

You can try reseting the root password by running MySQL in Safe Mode.

以下是步骤:

  1. 停止MySQL:

  1. Stop MySQL:

sudo /usr/local/mysql/support-files/mysql.server stop

以安全模式启动它:

sudo mysqld_safe --skip-grant-tables

这将是一个持续执行的命令,直到该过程完成为止,因此打开另一个外壳程序/终端窗口,然后..

This will be an ongoing command until the process is finished so open another shell/terminal window, and..

  1. 以root用户身份登录且没有密码:

  1. Log in without a password as root:

mysql -u root

更新root(和任何其他用户的)密码

Update root (and any other user's) password)

FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; \q

FLUSH PRIVILEGES; ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass'; \q

以正常模式重启MySQL

Restart MySQL in normal mode

sudo /usr/local/mysql/support-files/mysql.server start

参考: https://coolestguidesontheplanet.com/how-更改mysql根密码/

注意:这是非常标准的重置过程,但是与mysql参考文档相比,以上指南中的记录更好.

Note: this is pretty standard reset procedure, but just documented better in the above guide compared to mysql reference docs.

这篇关于如何在Mac OS 10.13.3中重置我的mysql密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆