只有在指定端口时才能连接到macos上的mysql 8

dtcbnfnu  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(178)

我在macos high sierra(10.13.6)上安装了mysql 8.0.12:

$ brew info mysql
mysql: stable 8.0.12 (bottled)
Open source relational database management system
https://dev.mysql.com/doc/refman/8.0/en/
Conflicts with:
  ...
/usr/local/Cellar/mysql/8.0.12 (255 files, 233.0MB) *
  Poured from bottle on 2018-09-04 at 11:09:42
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/mysql.rb
==> Dependencies
Build: cmake ✔
Required: openssl ✔
==> Requirements
Required: macOS >= 10.10 ✔
==> Options
...

这是我的书的内容 my.cnf 文件:


# Default Homebrew MySQL server config

[mysqld]

# Only allow connections from localhost

bind-address = 127.0.0.1

问题是当我通过自制服务启动mysql时:

brew services start mysql

并检查它是否正在运行:

$ brew services list
Name  Status  User Plist
mysql started jhl  /Users/jhl/Library/LaunchAgents/homebrew.mxcl.mysql.plist

$ ps aux | grep mysql
jhl               8609   0.0  0.0  4267768    900 s004  S+   11:21AM 0:00.00 grep mysql
jhl               8364   0.0  2.2  4896156 367368   ??  S    11:18AM   0:00.96 /usr/local/opt/mysql/bin/mysqld --basedir=/usr/local/opt/mysql --datadir=/usr/local/var/mysql --plugin-dir=/usr/local/opt/mysql/lib/plugin --log-error=jhls-MacBook-Pro.local.err --pid-file=jhls-MacBook-Pro.local.pid
jhl               8275   0.0  0.0  4282688   1300   ??  S    11:18AM   0:00.02 /bin/sh /usr/local/opt/mysql/bin/mysqld_safe --datadir=/usr/local/var/mysql
jhl               4558   0.0  0.0  4298668   3352 s000  S+   11:01AM   0:00.04 view /usr/local/var/mysql/jhls-MacBook-Pro.local.err

$ lsof -i :3306
COMMAND  PID USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
mysqld  8364  jhl   19u  IPv4 0xb949031a3ab21e7b      0t0  TCP localhost:mysql (LISTEN)

我无法连接到 mysqld 使用默认选项:

$ mysql -uroot
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (61)

我必须始终指定端口:

$ mysql -uroot -P 3306
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.12 Homebrew
...
mysql>

这在命令行上运行得很好,但在尝试连接到其他数据库工具(如rubymine中的数据库窗口)时,我运气不佳。我已经从自制软件中多次重新安装了mysql(版本8)和mysql版本5.7(确保每次都进行完全卸载),而这个问题似乎仍然存在于我尝试使用的所有版本上,这让我认为这是一个网络问题。我甚至试过指定 port 在两个 [client] 以及 [mysqld] 部分 my.cnf ,但没有运气。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题