我正在尝试在mac os 10.6上使用Homebrew by brew安装MySQL 5.1.52。
一切都很顺利,我也成功地使用mysql_install_db。
然而,当我试图连接到服务器使用:
/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin -u root password 'mypass'
我得到:
/usr/local/Cellar/mysql/5.1.52/bin/mysqladmin: connect to server at 'localhost'
failed error: 'Access denied for user 'root'@'localhost' (using password: NO)'
我尝试访问mysqladmin或mysql使用-u root - root以及,
但是有没有密码都不行。
这是全新机器上的全新安装,据我所知,新安装必须在没有根密码的情况下访问。我还试过:
/usr/local/Cellar/mysql/5.1.52/bin/mysql_secure_installation
但我也得到了
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
只是在之前的回答中添加一些东西-当从MySql 5.6升级到MySql 8.0时,我遵循了这里提供的步骤来进行干净的卸载,但我得到了以下错误
2019-11-05T07:57:31.359304Z 0 [ERROR] [MY-000077] [Server] /usr/local/Cellar/mysql/8.0.18/bin/mysqld: Error while setting value 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' to 'sql_mode'.
2019-11-05T07:57:31.359330Z 0 [ERROR] [MY-013236] [Server] The designated data directory /usr/local/var/mysql is unusable. You can remove all files that the server added to it.
2019-11-05T07:57:31.359413Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-11-05T07:57:31.359514Z 0 [Note] [MY-010120] [Server] Binlog end
我花了些时间才想明白。在这里找到了一个线索:
https://discourse.brew.sh/t/clean-removal-of-mysql/2251
因此,我的问题的关键是在卸载后删除/usr/local/etc/my.cnf文件。
在完成最后一步之后,MySql终于开始工作了。