简体   繁体   English

Docker mariadb 111 错误尝试连接

[英]Docker mariadb 111 error trying to connect

I have two instances of mariadb that I am trying to run (I need one for backwards compatibility).我有两个正在尝试运行的 mariadb 实例(我需要一个以实现向后兼容性)。 Here is the docker-compose.yml for both of them:这是他们两个的 docker-compose.yml:

  db:
    container_name: db
    image: mariadb:latest
    ports:
      - "3306:3306"
    networks:
      devel:
        ipv4_address: 172.19.0.105
    volumes:
      - "${DATA_DIR}/mariadb:/var/lib/mysql"
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 1
  db2:
    container_name: db2
    image: mariadb:10.2.37
    ports:
      - "3307:3306"
    networks:
      devel:
        ipv4_address: 172.19.0.106
    volumes:
      - "${DATA_DIR}/mariadb2:/var/lib/mysql"
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 1

I can connect to the first one, the one labelled db, no problem, but I get the following error for the second one:我可以连接到第一个,即标记为 db 的那个,没问题,但是第二个出现以下错误:

ERROR 2003 (HY000): Can't connect to MySQL server on '172.19.0.106' (111)

Here is the command I am trying to run to access it:这是我试图运行以访问它的命令:

mysql --user=root --host=172.19.0.106 --port=3307

I'm not sure why it can't connect.我不确定为什么它无法连接。 The information looks correct, but it's not working, so I don't know what I did wrong.信息看起来正确,但它不起作用,所以我不知道我做错了什么。

Also, the ${DATA_DIR} is a variable that is apart of a command to start the docker containers, so that is supposed to be there and is correct, in case anyone is wondering.此外, ${DATA_DIR}是一个变量,它是启动 docker 容器的命令的一部分,因此它应该存在并且是正确的,以防有人想知道。

Update: Here is my docker log for db2:更新:这是我的 db2 的 docker 日志:

2021-03-16 21:53:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.2.37+maria~bionic started.
2021-03-16 21:53:54+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-03-16 21:53:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.2.37+maria~bionic started.
2021-03-16 21:53:55 140078898230976 [Note] mysqld (mysqld 10.2.37-MariaDB-1:10.2.37+maria~bionic) starting as process 1 ...
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Uses event mutexes
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Compressed tables use zlib 1.2.11
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Using Linux native AIO
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Number of pools: 1
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Using SSE2 crc32 instructions
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Initializing buffer pool, total size = 256M, instances = 1, chunk size = 128M
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Completed initialization of buffer pool
2021-03-16 21:53:55 140078171240192 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-03-16 21:53:55 140078898230976 [Warning] InnoDB: Failed to set O_DIRECT on file./ibdata1;OPEN: Invalid argument, ccontinuing anyway. O_DIRECT is known to result in 'Invalid argument' on Linux on tmpfs, see MySQL Bug#26662.
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Setting log file ./ib_logfile101 size to 50331648 bytes
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Setting log file ./ib_logfile1 size to 50331648 bytes
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: New log files created, LSN=8280100
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Highest supported file format is Barracuda.
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: 128 out of 128 rollback segments are active.
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: Waiting for purge to start
2021-03-16 21:53:55 140078898230976 [Note] InnoDB: 5.7.33 started; log sequence number 8280588
2021-03-16 21:53:55 140077934044928 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2021-03-16 21:53:55 140078898230976 [Note] Plugin 'FEEDBACK' is disabled.
2021-03-16 21:53:55 140078898230976 [Note] Server socket created on IP: '::'.
2021-03-16 21:53:55 140078898230976 [Warning] 'proxies_priv' entry '@% root@98c35665786d' ignored in --skip-name-resolve mode.
2021-03-16 21:53:55 140078898230976 [Note] Reading of all Master_info entries succeeded
2021-03-16 21:53:55 140078898230976 [Note] Added new Master_info '' to hash table
2021-03-16 21:53:55 140078898230976 [Note] mysqld: ready for connections.
Version: '10.2.37-MariaDB-1:10.2.37+maria~bionic'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2021-03-16 21:53:56 140077934044928 [Note] InnoDB: Buffer pool(s) load completed at 210316 21:53:56

Use localhost ( 127.0.0.1 ) as host instead of the IP address of the dock container because you have a bound port.使用 localhost ( 127.0.0.1 ) 作为主机,而不是码头容器的 IP 地址,因为您有一个绑定端口。 By default, the mysql client uses the sock file on the local host instead of the tcp protocol.默认情况下,mysql 客户端使用本地主机上的 sock 文件,而不是 tcp 协议。 Try the following command:尝试以下命令:

mysql --user=root --host=127.0.0.1 --port=3307 --protocol=tcp

暂无
暂无

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

相关问题 Mariadb docker容器无法使用Python连接到主机上的MySQL服务器(111连接被拒绝) - Mariadb docker container Can't connect to MySQL server on host (111 Connection refused) with Python Django docker容器无法连接到mysql容器,错误“无法连接到'db'上的MySQL服务器(111)”) - Django docker container failed to connect to mysql container with error “Can't connect to MySQL server on 'db' (111)”) 在Docker上使用Django时出错-“无法在'127.0.0.1'(111)上连接到MySQL服务器”) - Error using Django with Docker - “Can't connect to MySQL server on '127.0.0.1' (111)”) MySQL 错误 111 无法连接到服务器 - MySQL Error 111 Can't connect to server 尝试连接到Google-Cloud中的MariaDB数据库,但无法连接或不显示任何错误报告 - Trying to connect to a MariaDB database in google-cloud but cant connect nor show any error report Spring 启动应用程序无法连接到 mariadb(在 Docker 中) - Spring boot application unable to connect to mariadb (in Docker) 无法连接到本地主机(MariaDB Docker 上的 MySQL Workbench) - Unable to Connect to Localhost (MySQL Workbench on MariaDB Docker) "从 Docker 容器使用 localhost 连接到 MariaDB" - Connect to MariaDB with localhost from Docker container Docker无法使用PHP连接到mariadb - Docker can't connect to mariadb with PHP 将 nodejs api 连接到 mariadb docker 容器 - connect nodejs api to mariadb docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM