繁体   English   中英

如何从 Sequel Pro 连接到 docker mysql 容器

[英]How to connect to docker mysql container from Sequel Pro

我花了将近 2 周的时间在谷歌上搜索并尝试了大量不同的解决方案,但似乎没有一个对我有用。

我正在使用 Docker for Mac(我的工具栏中有一个鲸鱼图标)。

我正在使用此命令来创建 mysql 容器:

docker container run -d -p 3306:3306 --name=database -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=local -e MYSQL_PASSWORD=local_password -v ~/.databases/mysql:/var/lib/mysql mysql

这是docker container logs database的输出

2018-10-02T10:45:37.234437Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated
and will be removed in a future release.
2018-10-02T10:45:37.235186Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.12) starting as process 1
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
mbind: Operation not permitted
2018-10-02T10:45:37.927574Z 0 [System] [MY-010229] [Server] Starting crash recovery...
2018-10-02T10:45:37.927670Z 0 [System] [MY-010232] [Server] Crash recovery finished.
2018-10-02T10:45:38.012828Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-10-02T10:45:38.022161Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different
 directory.
2018-10-02T10:45:38.034910Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
2018-10-02T10:45:38.034958Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-10-02T10:45:38.034976Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-10-02T10:45:38.034988Z 0 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2018-10-02T10:45:38.035012Z 0 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.2018-10-02T10:45:38.035036Z 0 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-10-02T10:45:38.035053Z 0 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2018-10-02T10:45:38.041121Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2018-10-02T10:45:38.041159Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2018-10-02T10:45:38.048971Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.12'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL

我正在尝试使用以下设置从 Sequel Pro 连接到此容器:

Host: 127.0.0.1
Username: local
Password: local_password

我收到以下错误:

Unable to connect to host 127.0.0.1, or the request timed out.

Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).

MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found

任何其他遇到此问题的人,事实证明这是由于最新(8+)版本的mysql 5.7 版本工作正常。

您可以尝试将主机端口更改为 33306 而不是 3306 吗?

docker container run -d -p 33306:3306 --name=database -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=local -e MYSQL_PASSWORD=local_password -v ~/.databases/mysql:/var/lib/mysql mysql

您还可以尝试什么,进入容器并验证 MySQL 引擎是否在那里工作。 您可以通过执行以下命令来做到这一点:

docker exec -ti database bash mysql -p

如果您仍在寻找解决方案,可以尝试以下方法。 您可能需要使用以下方法从所有来源向您的用户提供访问权限。 grant all privileges on *.* to 'root'@'%' identified by ''; 刷新权限;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM