卡住了用户"root" @"localhost"的访问权限-终端机,Mac [英] Stuck with Access Denied for user 'root'@'localhost' - Terminal, Mac
问题描述
尝试访问mysql时,我被卡住了.这是我的第一次,请耐心等待.
I am stuck when trying to access mysql. It's my first time so please be patient with me.
最初,我尝试设置Ruby和Rails,并且一切正常运行,但期望连接到服务器时访问被拒绝,所以我运行了此命令.
Initially I was try to set up Ruby and Rails and everything worked perfrectly expect access denied when connecting to the server, SO I ran this command.
mysql -uroot -p
我尝试了各种密码,包括将其保留为空白并出现此错误.
I've tried various passwords including leaving it blank and get this error.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
我假设我需要重置root用户的密码,但似乎无法正常工作.
I am assuming I need to reset the password for root user but I just can't seem to get it to work.
推荐答案
一种方法:
- 停止您的MySQL服务器.
-
使用
--skip-grant-tables
选项启动您的MySQL服务器.它使您无需密码即可连接到服务器.
- stop your MySQL server.
start your MySQL server with the
--skip-grant-tables
option. It allows you to connect to the server without a password.
/path/to/mysqld --skip-grant-tables &
使用mysql客户端连接到服务器:
connect to your server using the mysql client:
mysql
更改根密码(将 NewPassord 替换为所需的密码):
change the root password (replace NewPassord by what you want):
UPDATE mysql.user SET password=PASSWORD('NewPassord') WHERE user='root';
重新启动MySQL服务器.
restart yout MySQL server.
还有其他方法可以重置MySQL根密码: http://dev.mysql.com/doc/refman/5.6/en/reset-permissions.html
There are others ways to reset the MySQL root password: http://dev.mysql.com/doc/refman/5.6/en/resetting-permissions.html
这篇关于卡住了用户"root" @"localhost"的访问权限-终端机,Mac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!