gpt4 book ai didi

mysql - 避开 'Access denied for user ' root'@'localhost'(使用密码: NO)'

转载 作者:行者123 更新时间:2023-11-29 05:15:21 25 4
gpt4 key购买 nike

如何安装并使用 mysql?

我试过:

$ brew install mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.7.9.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/mysql-5.7.9.yosemite.bottle.tar.gz
==> Pouring mysql-5.7.9.yosemite.bottle.tar.gz
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.

To connect:
mysql -uroot

To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
==> Summary
🍺 /usr/local/Cellar/mysql/5.7.9: 12629 files, 464M
$ mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
$ mysql.server start
Starting MySQL
SUCCESS!
$ mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
$

最佳答案

对我来说,我的计算机上已经安装了 mysql,因此在那里设置了密码之类的。在花了数小时尝试所有解决方案后,这对我有用:

$ brew services stop mysql
$ pkill mysqld
$ rm -rf /usr/local/var/mysql/ # NOTE: this will delete your existing database!!!
$ brew postinstall mysql
$ brew services restart mysql
$ mysql -uroot

所有归功于@Ghrua

关于mysql - 避开 'Access denied for user ' root'@'localhost'(使用密码: NO)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33684161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com