无法在 mac 上为 mysql@5.6 启动 mysql 服务器

Unable to start mysql server on mac for mysql@5.6

我正在尝试在我的 mac 上设置 mysql@5.6。我在本地有多个版本的 mysql,我删除了所有版本,按照 post 以下步骤安装了 mysql@5.6:After MySQL install via Brew, I get the error - The server quit without updating PID file:

brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo rm -rf /usr/local/var/mysql

brew install mysql@5.6

ln -s /usr/local/Cellar/mysql\@5.6/5.6.47/bin/mysql /usr/local/bin/mysql

我在 /etc 中没有任何 my.cnf 文件,所以我用以下内容创建了这个文件:

 [mysqld]
 bind-address = 127.0.0.1

现在在执行 mysql.server 启动时 ,出现以下错误:

... ERROR! The server quit without updating PID file (/usr/local/var/mysql/my.pid).

我检查了日志文件,发现以下错误:

   2020-04-28 11:17:49 48498 [Note] Plugin 'FEDERATED' is disabled.
/usr/local/opt/mysql@5.6/bin/mysqld: Table 'mysql.plugin' doesn't exist
2020-04-28 11:17:49 48498 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2020-04-28 11:17:49 48498 [Note] InnoDB: Using atomics to ref count buffer pool pages
2020-04-28 11:17:49 48498 [Note] InnoDB: The InnoDB memory heap is disabled
2020-04-28 11:17:49 48498 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-04-28 11:17:49 48498 [Note] InnoDB: Memory barrier is not used
2020-04-28 11:17:49 48498 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-04-28 11:17:49 48498 [Note] InnoDB: Using CPU crc32 instructions
2020-04-28 11:17:49 48498 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2020-04-28 11:17:49 48498 [Note] InnoDB: Completed initialization of buffer pool
2020-04-28 11:17:49 48498 [Note] InnoDB: Highest supported file format is Barracuda.
2020-04-28 11:17:49 48498 [Note] InnoDB: 128 rollback segment(s) are active.
2020-04-28 11:17:49 48498 [Note] InnoDB: Waiting for purge to start
2020-04-28 11:17:49 48498 [Note] InnoDB: 5.6.47 started; log sequence number 1603477
2020-04-28 11:17:49 48498 [ERROR] /usr/local/opt/mysql@5.6/bin/mysqld: unknown variable 'mysqlx-bind-address=127.0.0.1'
2020-04-28 11:17:49 48498 [ERROR] Aborting

然后我按照这个 post: 和 运行 以下命令:

  /usr/local/Cellar/mysql\@5.6/5.6.47/bin/mysqld --initialize-insecure

但我仍然看到同样的错误。

编辑:

我找到了 my.cnf 文件,它位于 /usr/local/etc/

我删除了 mysqlx-bind-address,现在我收到以下错误:

2020-04-28 14:16:13 97501 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2020-04-28 14:16:35 98713 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

我已经解决了这个 运行 下面的命令:

mysql_install_db --verbose --user=`whoami` --basedir=/usr/local/Cellar/mysql\@5.6/5.6.47 --datadir=/usr/local/var/mysql --tmpdir=/tmp

我从这里得到这个想法:https://coderwall.com/p/os6woq/uninstall-all-those-broken-versions-of-mysql-and-re-install-it-with-brew-on-mac-mavericks

然后 mysql.server start,mysql 数据库服务器正常启动。谢谢

刚刚在我的系统上解决了这个问题。事实证明,有问题的行 (mysqlx-bind-address=127.0.0.1) 在 /usr/local/etc/my.cnf 中,而每个人都只是说检查 /etc/my.cnf.

删除有问题的文件后(可能是 MySQL 8 安装的遗留问题),MySQL 5.6 安装工作正常。