MySQL密码问题(Mac OS X Lion) [英] MySQL password issues (mac OS X Lion)
问题描述
我试图在Mac OS X Lion的终端中为MySQL设置root密码,但是出现问题.每次我使用该行:
I am trying to set the root password for MySQL in the terminal in Mac OS X Lion, and I am having issues. Every time I use the line:
/usr/local/mysql/bin/mysqladmin -u root password ****** (where ****** is the password I want to set)
我收到错误:
/usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
我以前没有设置密码,所以我不知道为什么收到此错误.
I have not set a password previously, so I do not know why I am receiving this error.
推荐答案
以下是重置root用户密码的过程.
Here is the procedure to reset password of root user.
1)停止mysql(杀死mysql进程或运行以下命令)
1) Stop mysql (Kill mysql process or run following command)
sudo /usr/local/mysql/support-files/mysql.server stop
2)以安全模式启动
sudo mysqld_safe --skip-grant-tables
3)打开另一个终端并运行以下命令(保持最后一个终端打开)
3) Open another terminal and run the following command (Keep last terminal open)
mysql -u root
4)在mysql控制台上使用合适的新密码运行以下命令
4) Run the following command with suitable new password on the mysql console
对于MySQL 5.7 +:
For MySQL 5.7+:
mysql > UPDATE mysql.user SET authentication_string=PASSWORD('password') WHERE User='root';
对于早期版本:
mysql > UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
5)mysql > FLUSH PRIVILEGES;
6)从两个终端退出并打开新终端,并以root用户和新密码连接到mysql
6) Quit from both terminals and open new terminal and connect to mysql with root user and new password
mysql -uroot -p
这篇关于MySQL密码问题(Mac OS X Lion)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!