MySQL - 错误 1045 - 访问被拒绝
在某种程度上,当我尝试通过命令行访问 MySQL 时,我设法收到此错误:
[root@localhost ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
我尝试使用此 HowTo 重置密码,但没有任何运气。
我已经卸载了 mysql completley 并重新安装,但仍然被要求输入密码。 我不知道为什么会这样!
有人可以帮我获得 MySQL 的默认安装吗?
环境
Fedora Core 10,完全根访问权限,安装了 Apache 和 PHP
感谢您的帮助!
编辑
对于所有那些想要节省自己几个小时“咳血”的人 - 当您卸载 MySQl 时完全删除留下的所有内容。 如果您不这样做,它将永远不会是全新安装。
In some way I have managed to get this error when I try to access into MySQL via the command line:
[root@localhost ~]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I have tried resetting the password without any luck using this HowTo.
I have uninstalled mysql completley and reinstalled but I still get asked for a password. I have no idea why this is the case!
Can someone please help me get a default install of MySQL.
Environment
Fedora Core 10, Full Root Access, Apache and PHP installed
Thank you for any help!!
EDIT
To all those that would like to save themselves a few hours of "blood coughing" - when you uninstall MySQl completely delete everything that is left behind. If you don't do this, it will never be a FRESH install.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您实际上已经设置了 root 密码,并且刚刚丢失/忘记了它:
使用skip-grant-tables 选项手动重新启动它:
mysqld_safe --skip-grant-tables
现在,打开一个新的终端窗口并运行MySQL客户端:
mysql -u root
使用以下 MySQL 命令手动重置 root 密码:<代码>更新 mysql.user SET 密码=PASSWORD('密码') WHERE User='root';
如果您使用 MySQL 5.7(在终端中使用 mysql --version 检查),则命令为:
使用此 MySQL 命令刷新权限:
FLUSH PRIVILEGES;
来自 http:// /www.tech-faq.com/reset-mysql-password.shtml
(也许这不是你所需要的,Abs,但我认为这对于将来遇到这个问题的人来说可能很有用)
If you actually have set a root password and you've just lost/forgotten it:
Restart it manually with the skip-grant-tables option:
mysqld_safe --skip-grant-tables
Now, open a new terminal window and run the MySQL client:
mysql -u root
Reset the root password manually with this MySQL command:
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
If you are using MySQL 5.7 (check using mysql --version in the Terminal) then the command is:
Flush the privileges with this MySQL command:
FLUSH PRIVILEGES;
From http://www.tech-faq.com/reset-mysql-password.shtml
(Maybe this isn't what you need, Abs, but I figure it could be useful for people stumbling across this question in the future)
尝试不使用任何密码进行连接:
我相信 root 帐户的初始默认设置是没有密码的(显然应该尽快更改)。
Try connecting without any password:
I believe the initial default is no password for the root account (which should obviously be changed as soon as possible).
使用此命令检查可能的输出
输出
使用GRANT命令再次授予用户admin密码
输出将与他的类似,
然后检查 GRANT LIST ,如果需要允许所需的用户(例如用户“admin”)登录,则 然后使用一次GRANT 命令并执行该命令。
现在应该允许用户登录。
use this command to check the possible output
output
Grant the user admin with password using GRANT command once again
then check the GRANT LIST the out put will be like his
if the desired user for example user 'admin' is need to be allowed login then use once GRANT command and execute the command.
Now the user should be allowed to login.
当前 root 密码必须为空。
然后在“新 root 密码”下输入您的密码并确认。
The current root password must be empty.
Then under "new root password" enter your password and confirm.
同花顺特权;
出口
PASSWORD ('') 必须为空 然后
FLUSH PRIVILEGES;
exit
PASSWORD ('') is must empty
我遇到了同样的错误,但这是因为
password_expired
设置为Y
。 您可以按照与当前接受的答案相同的方法来解决该问题,但改为执行 MySQL 查询:I had the same error, but it was because
password_expired
was set toY
. You can fix that issue by following the same approach as the currently accepted answer, but instead executing the MySQL query:我无法连接到 MySql 管理员。 我通过创建另一个用户并分配所有权限来修复它。
我用那个新用户登录并且它起作用了。
I could not connect to MySql Administrator. I fixed it by creating another user and assigning all the permissions.
I logged in with that new user and it worked.