【问题标题】:mysql setup issue on Mac systemMac系统上的mysql设置问题
【发布时间】:2018-04-13 10:46:14
【问题描述】:

我已经使用命令 brew install mysql 安装了 mysql。之后为root设置密码。我仍然无法登录 mysql shell

brew install mysql
    sheetal$ mysql -uroot
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    sheetal$ mysql -uroot -p
    Enter password: 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    sheetal$ sudo mysql -uroot -p
    Password:
    Enter password: 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    sheetal$ mysql_secure_installation

    Securing the MySQL server deployment.

    Enter password for user root: 
    Error: Access denied for user 'root'@'localhost' (using password: YES)

【问题讨论】:

  • 我认为您不需要考虑在此处使用sudo...凭据问题出在 MySQL,而不是您的 Linux 安装。您确定您使用的是您实际设置的密码吗?如果你是,那我没有解释。也许由于某种原因没有设置。
  • @TimBiegeleisen:OP 使用的是 macOS not Linux。
  • 它使用的是 MacOS@TimBiegeleisen
  • mysql_secure_installation 保护 MySQL 服务器部署。输入用户 root 的密码:错误:用户 'root'@'localhost' 的访问被拒绝(使用密码:YES)
  • @l'L'l 是的,我现在是这个,但 Mac OS 是 Linux 的一个分支(我认为)。无论如何,我的评论仍然适用于 MacOS。

标签: mysql ruby-on-rails macos


【解决方案1】:

您似乎忘记了密码。要重置 root 密码,您需要使用 --skip-grant-tables 选项启动 mysql 服务器。这允许您无需任何密码即可登录到您的 mysql 控制台。

$mysql.server start --skip-grant-tables
$mysql
mysql> FLUSH PRIVILEGES;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
mysql> quit;
$mysql.server restart

现在您应该可以使用新密码登录了。

有other ways 可以做到这一点,但我发现这是最简单的。

【讨论】:

    猜你喜欢
    • 2020-05-20
    • 1970-01-01
    • 2020-08-19
    • 2014-01-21
    • 2011-08-21
    • 2011-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多