Forgot the MySQL root user password on Mac OS X system and need to reset.

Have you forgotten your Mac OS X 'ROOT' password and need to reset it? Follow these 4 simple steps:
你是否忘记MySQL的根用户的登录密码?根据以下4点可以实现重设密码:

  1. Stop the mysqld server. Typically this can be done by from 'System Prefrences' > MySQL > 'Stop MySQL Server'
    (先在设置中关闭MySQL运行的服务)

  2. Start the server in safe mode with privilege bypass From a terminal:
    (在终端中使用以下命令使用安全模式开启MySQL服务)

sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
  1. In a new terminal window:
    (刚才的终端不要理它,重新开启一个新的终端窗口,然后输入以下的命令)
 a). sudo /usr/local/mysql/bin/mysql -u root

(下面的这个命令中,把NewPassword替换成你自己的密码)

  b). UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE user='root'
c). FLUSH PRIVILEGES
d). \q

<注意:上面的a、b、c、d是编号,不属于命令的内容。>

  1. Stop the mysqld server again and restart it in normal mode.
    (在设置中再次关闭MySQL运行的服务,然后又开启服务)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容