【问题标题】:Fail to change password of mysql on Mac在 Mac 上更改 mysql 的密码失败
【发布时间】:2016-03-08 07:36:48
【问题描述】:

我想在我的 Mac 上更改 mysql 的密码。我相信我以前从未改变过它。用户和密码都是root,我访问没有问题。

但是,当我按照网上找到的说明进行操作时,输入以下命令: /Applications/MAMP/Library/bin/mysqladmin -u root -p password [my new password]

然后我在所需的密码中输入了“root”。

我收到了这样的回复: "Access denied for user 'root'@'localhost' (using password: YES)"

我尝试用我找到的方法解决它:

  1. 停止MYSQL:# /etc/init.d/mysql stop or# stop mysql or #service mysql stop
  2. 输入这个:# mysql_safe --user=mysql --skip-grant-tables --skip-networking &
  3. 登录MYSQL:#mysql -uroot mysql# mysql -uroot mysql -p 然后输入root密码,输入MYSQL
  4. 重置root密码:mysql>UPDATE user SET Password=[new password] where USER = "root";

还有几个步骤我没有测试。因为它从第一步开始就不起作用。这让我觉得这可能不是解决我的问题的正确方法。

我已经寻找了几个小时的答案,现在只能尝试寻求解决方案。请帮我一把。

【问题讨论】:

    标签: mysql macos passwords


    【解决方案1】:

    在您的方法(第 2 步)中,您没有包含正确的用户:

    --user=root
    

    它应该是root,尽管它当前指定的是mysql

    【讨论】:

    • 感谢您的更正。问题是,即使我输入#stop mysql 或其他两个,命令行也没有显示任何内容!
    • @SamuelLin:您需要在 MAMP 中停止服务器,杀死它的 MySQL 进程,或者尝试使用绝对 MAMP 路径停止服务; (第一种方法可能是最简单的)——然后退出 MAMP。命令应使用 MAMP 路径(例如,/Applications/MAMP/Library/bin/mysqld_safe 等)。
    • 我已经通过单击 MAMP 上的停止服务器按钮来停止服务器,并准确输入 /Applications/MAMP/Library/bin/mysql_safe/Applications/MAMP/Library/bin/mysql_safe --user=root mysql --skip-grant-tables --skip-networking & 但它的响应是:No such file or directory 我是新手,对这些细节感到抱歉我的问题。
    • 尝试在路径的第一个 / 前面使用句点,或者 cd 进入它(例如 ./Applications/MAMP/...)。
    • 谢谢回复,我试过了。还是不行。
    猜你喜欢
    • 2012-03-31
    • 1970-01-01
    • 2021-06-27
    • 2013-09-04
    • 2021-07-13
    • 1970-01-01
    • 2017-08-13
    • 2014-08-27
    • 1970-01-01
    相关资源
    最近更新 更多