尝试在Mac OS High Sierra上使用brew安装mysql5.7。
我使用了以下命令:
sudo rm -rf /usr/local/var/mysql/
brew install [email protected]
brew postinstall [email protected]
出现以下错误:
2019-10-05T02:59:24.136970Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-10-05T02:59:24.138997Z 0 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2019-10-05T02:59:24.215676Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-10-05T02:59:24.232279Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-10-05T02:59:24.286214Z 0 [ERROR] unknown variable 'mysqlx-bind-address=127.0.0.1'
2019-10-05T02:59:24.286281Z 0 [ERROR] Aborting
因此我无法做到:
mysql_secure_installation
抛出:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
如果您能够找到您的
my.cnf
文件(对我来说,它位于 /usr/local/etc/my.cnf
中),您应该删除以下行:
mysqlx-bind-address = 127.0.0.1
就像@sbkrogers所说,必须删除该行,但因为我使用Homebrew来安装[电子邮件受保护]:
我的文件位于
/opt/homebrew/etc/my.cnf
。在哪里删除
mysqlx-bind-address = 127.0.0.1
第一次中止安装后,需要删除以下文件夹:
/opt/homebrew/Cellar/[email protected]
/opt/homebrew/var/mysql
...然后尝试再次安装。
brew install mysql
安装成功后,重启终端
对于我们的例子,这是因为 mysql 是在 mariadb 之前安装的。因此 my.cnf 已经创建。 mysql 中的
my.cnf
缺少 mariadb 所需的一些行。
我们修复的步骤:
# uninstall mariadb
brew remove mariadb
# rename my.cnf to something else
# the homebrew etc directory is on /opt/homebrew/etc
# cd /opt/homebrew/etc
mv my.cnf my.cnf.default
# re-install
brew install mariadb
# restart and check the status
brew services restart mariadb && brew service info mariadb