mysql:在macos上安装后立即拒绝用户“root”@“localhost”的访问

u0njafvf  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(481)

我刚刚从mysql网站下载的dmg包在macos highsierrav10.13.4上安装了mysql v8.0.11。安装程序在安装过程中没有要求任何特权或访问设置。安装完成后,我尝试运行: $ mysql -u root 我被退回了错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) . 然后我试着用 sudo 但我还是被退回了同样的错误。
通过对类似问题的回答,我试着跑: sudo /etc/init.d/mysql stop 它返回错误 sudo: /etc/init.d/mysql: command not found 如果我继续尝试下一步 sudo mysqld_safe --skip-grant-tables 我收到了输出 [2] 27806 [2] + 27806 suspended (tty output) sudo mysqld_safe --skip-grant-tables 还有,跑步 mysqld --skip-grant-tables 返回以下错误: mysqld: Can't change dir to '/usr/local/mysql-8.0.11-macos10.13-x86_64/data/' (OS errno 13 - Permission denied) 2018-04-20T14:29:23.579709Z 0 [System] [MY-010116] [Server] /usr/local/mysql-8.0.11-macos10.13-x86_64/bin/mysqld (mysqld 8.0.11) starting as process 29470 2018-04-20T14:29:23.593533Z 0 [Warning] [MY-010091] [Server] Can't create test file /usr/local/mysql-8.0.11-macos10.13-x86_64/data/Faheems-MacBook-Air.lower-test 2018-04-20T14:29:23.593582Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /usr/local/mysql-8.0.11-macos10.13-x86_64/data/ is case insensitive 2018-04-20T14:29:23.593863Z 0 [ERROR] [MY-010172] [Server] failed to set datadir to /usr/local/mysql-8.0.11-macos10.13-x86_64/data/ 2018-04-20T14:29:23.593889Z 0 [ERROR] [MY-010119] [Server] Aborting 2018-04-20T14:29:23.594332Z 0 [System] [MY-010910] [Server] /usr/local/mysql-8.0.11-macos10.13-x86_64/bin/mysqld: Shutdown complete (mysqld 8.0.11) MySQL Community Server - GPL. 它仍然不能解决最初的错误或者让我运行mysql。我试过几乎所有相关问题的答案,但都不管用。
感谢任何能帮忙的人!

hujrc8aj

hujrc8aj1#

在尝试了一些修复之后,我用 $ sudo mysql.server start 然后继续 $ mysql_secure_installation 为根用户设置密码。
这对我有用。
注:自制要求你先做 mysql_secure_installation 在第一次启动mysql服务器之前,但是这导致了上述错误。

相关问题