我无法从运行MariaDB容器的主机连接MySQL。以下是一些有关环境的信息:
docker compose
- 文件version: '3.1'
services:
db:
image: mariadb
restart: always
environment:
BIND-ADDRESS: 0.0.0.0
MYSQL_ROOT_PASSWORD: example
ports:
- 3306:3006
adminer:
image: adminer
restart: always
ports:
- 8080:8080
通过docker exec -it rancherclientplatform_db_1 /bin/bash
与容器连接以及与mysql -uroot -p
的连接无疑令人惊讶。
拨款如下:
MariaDB [(none)]> SHOW GRANTS;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost
|
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*57237BB49761F29AB9724BA084E811D70C12393D' WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION
|
+----------------------------------------------------------------------------------------------------------------------------------------+
当我尝试连接主机时没有
mysql -uroot -p
或mysql -hlocalhost -uroot -p
或mysql -h127.0.0.1 -uroot -p
的工作。前2个因套接字错误而失败,-h127.0.0.1
失败
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0 "Internal error/check (Not system error)"
端口3306
本身似乎正确地发布到主机,如
nmap -p3306 localhost
发送
PORT STATE SERVICE
3306/tcp open mysql
关于该怎么做的任何想法?
答案 0 :(得分:1)
MariaDB默认端口是3306.
所以:
端口: - 3306:3006
如果您想使用端口3306访问localhost上的mariadb,您可能希望使用3306:3306映射端口