Have you forgotten your Mac OS X 'ROOT' password and need to reset it? Follow these 4 simple steps:
你是否忘记MySQL的根用户的登录密码?根据以下4点可以实现重设密码:
-
Stop the mysqld server. Typically this can be done by from 'System Prefrences' > MySQL > 'Stop MySQL Server'
(先在设置中关闭MySQL运行的服务) -
Start the server in safe mode with privilege bypass From a terminal:
(在终端中使用以下命令使用安全模式开启MySQL服务)
sudo /usr/local/mysql/bin/mysqld_safe --skip-grant-tables
- 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是编号,不属于命令的内容。>
- Stop the mysqld server again and restart it in normal mode.
(在设置中再次关闭MySQL运行的服务,然后又开启服务)
网友评论