所以我使用brew安装了mysql,然后运行brew install mysql(后来也运行brew reinstall mysql)。我尝试以 root 用户身份访问 mysql,但它不允许我这样做。
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -u root
To start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/mysql/bin/mysqld_safe --datadir\=/opt/homebrew/var/mysql
==> Summary
🍺 /opt/homebrew/Cellar/mysql/8.3.0_1: 323 files, 312.8MB
==> Running `brew cleanup mysql`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
(base) <mycomputer> ~ % mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
您可能需要先调用
brew services start mysql
命令以允许连接。