请大佬们给个指导,谢谢
提示:
2025/01/31 09:07:44 /build/model/main.go:92
[error] failed to initialize database, got error dial tcp 172.18.0.2:3306: connect: connection timed out
[FATAL] 2025/01/31 - 09:07:44 | [dial tcp 172.18.0.2:3306: connect: connection timed out]
14 个赞
只能多看看日志,有效信息太少。内网一般不会出现time out。 ip为啥设置为172.18.0.2,可以直接使用容器名称作为路径名。
需要给出 docker inspect mariadb容器名 的内容,不过初步来看,是使用容器内部ip地址访问,当然是不通的
看了半天找不到解决方案啊,求指导
2025-01-31 00:33:06+00:00 [Note] [Entrypoint]: Database files initialized
2025-01-31 00:33:06+00:00 [Note] [Entrypoint]: Starting temporary server
2025-01-31 00:33:06+00:00 [Note] [Entrypoint]: Waiting for server startup
2025-01-31 0:33:06 0 [Note] Starting MariaDB 11.6.2-MariaDB-ubu2404 source revision d8dad8c3b54cd09fefce7bc3b9749f427eed9709 server_uid 72+4ASMvYxproTQgRqIDplDA1XA= as process 86
2025-01-31 0:33:06 0 [Note] InnoDB: Compressed tables use zlib 1.3
2025-01-31 0:33:06 0 [Note] InnoDB: Number of transaction pools: 1
2025-01-31 0:33:06 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2025-01-31 0:33:06 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2025-01-31 0:33:06 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2025-01-31 0:33:06 0 [Note] InnoDB: Completed initialization of buffer pool
2025-01-31 0:33:06 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
2025-01-31 0:33:06 0 [Note] InnoDB: End of log at LSN=47629
2025-01-31 0:33:06 0 [Note] InnoDB: Opened 3 undo tablespaces
2025-01-31 0:33:06 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
2025-01-31 0:33:06 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2025-01-31 0:33:06 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2025-01-31 0:33:06 0 [Note] InnoDB: log sequence number 47629; transaction id 14
2025-01-31 0:33:06 0 [Note] Plugin 'FEEDBACK' is disabled.
2025-01-31 0:33:06 0 [Note] Plugin 'wsrep-provider' is disabled.
2025-01-31 0:33:08 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
2025-01-31 0:33:08 0 [Note] mariadbd: ready for connections.
Version: '11.6.2-MariaDB-ubu2404' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
2025-01-31 00:33:09+00:00 [Note] [Entrypoint]: Temporary server started.
2025-01-31 00:33:13+00:00 [Note] [Entrypoint]: Securing system users (equivalent to running mysql_secure_installation)
2025-01-31 00:33:14+00:00 [Note] [Entrypoint]: Stopping temporary server
2025-01-31 0:33:14 0 [Note] mariadbd (initiated by: unknown): Normal shutdown
2025-01-31 0:33:14 0 [Note] InnoDB: FTS optimize thread exiting.
2025-01-31 0:33:14 0 [Note] InnoDB: Starting shutdown...
2025-01-31 0:33:14 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2025-01-31 0:33:14 0 [Note] InnoDB: Buffer pool(s) dump completed at 250131 0:33:14
2025-01-31 0:33:14 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
2025-01-31 0:33:14 0 [Note] InnoDB: Shutdown completed; log sequence number 47629; transaction id 15
2025-01-31 0:33:15 0 [Note] mariadbd: Shutdown complete
2025-01-31 00:33:15+00:00 [Note] [Entrypoint]: Temporary server stopped
2025-01-31 00:33:15+00:00 [Note] [Entrypoint]: MariaDB init process done. Ready for start up.
2025-01-31 0:33:15 0 [Note] Starting MariaDB 11.6.2-MariaDB-ubu2404 source revision d8dad8c3b54cd09fefce7bc3b9749f427eed9709 server_uid 72+4ASMvYxproTQgRqIDplDA1XA= as process 1
2025-01-31 0:33:15 0 [Note] InnoDB: Compressed tables use zlib 1.3
2025-01-31 0:33:15 0 [Note] InnoDB: Number of transaction pools: 1
2025-01-31 0:33:15 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2025-01-31 0:33:15 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2025-01-31 0:33:15 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2025-01-31 0:33:15 0 [Note] InnoDB: Completed initialization of buffer pool
2025-01-31 0:33:15 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
2025-01-31 0:33:15 0 [Note] InnoDB: End of log at LSN=47629
2025-01-31 0:33:15 0 [Note] InnoDB: Opened 3 undo tablespaces
2025-01-31 0:33:15 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
2025-01-31 0:33:15 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2025-01-31 0:33:15 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2025-01-31 0:33:15 0 [Note] InnoDB: log sequence number 47629; transaction id 14
2025-01-31 0:33:15 0 [Note] Plugin 'FEEDBACK' is disabled.
2025-01-31 0:33:15 0 [Note] Plugin 'wsrep-provider' is disabled.
2025-01-31 0:33:15 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2025-01-31 0:33:15 0 [Note] InnoDB: Buffer pool(s) load completed at 250131 0:33:15
2025-01-31 0:33:16 0 [Note] Server socket created on IP: '0.0.0.0'.
2025-01-31 0:33:16 0 [Note] Server socket created on IP: '::'.
2025-01-31 0:33:16 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
2025-01-31 0:33:16 0 [Note] mariadbd: ready for connections.
Version: '11.6.2-MariaDB-ubu2404' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
2025-01-31 0:38:51 0 [Note] mariadbd (initiated by: unknown): Normal shutdown
2025-01-31 0:38:51 0 [Note] InnoDB: FTS optimize thread exiting.
2025-01-31 0:38:51 0 [Note] InnoDB: Starting shutdown...
2025-01-31 0:38:51 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2025-01-31 0:38:51 0 [Note] InnoDB: Buffer pool(s) dump completed at 250131 0:38:51
2025-01-31 0:38:51 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
2025-01-31 0:38:51 0 [Note] InnoDB: Shutdown completed; log sequence number 47629; transaction id 15
2025-01-31 0:38:51 0 [Note] mariadbd: Shutdown complete
2025-01-31 00:39:21+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.6.2+maria~ubu2404 started.
2025-01-31 00:39:22+00:00 [Warn] [Entrypoint]: /sys/fs/cgroup///memory.pressure not writable, functionality unavailable to MariaDB
2025-01-31 00:39:22+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-01-31 00:39:22+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:11.6.2+maria~ubu2404 started.
2025-01-31 00:39:22+00:00 [Note] [Entrypoint]: MariaDB upgrade not required
2025-01-31 0:39:23 0 [Note] Starting MariaDB 11.6.2-MariaDB-ubu2404 source revision d8dad8c3b54cd09fefce7bc3b9749f427eed9709 server_uid 72+4ASMvYxproTQgRqIDplDA1XA= as process 1
2025-01-31 0:39:23 0 [Note] InnoDB: Compressed tables use zlib 1.3
2025-01-31 0:39:23 0 [Note] InnoDB: Number of transaction pools: 1
2025-01-31 0:39:23 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2025-01-31 0:39:23 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2025-01-31 0:39:23 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2025-01-31 0:39:23 0 [Note] InnoDB: Completed initialization of buffer pool
2025-01-31 0:39:23 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
2025-01-31 0:39:23 0 [Note] InnoDB: End of log at LSN=47629
2025-01-31 0:39:23 0 [Note] InnoDB: Opened 3 undo tablespaces
2025-01-31 0:39:23 0 [Note] InnoDB: 128 rollback segments in 3 undo tablespaces are active.
2025-01-31 0:39:23 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2025-01-31 0:39:23 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2025-01-31 0:39:23 0 [Note] InnoDB: log sequence number 47629; transaction id 14
2025-01-31 0:39:23 0 [Note] Plugin 'FEEDBACK' is disabled.
2025-01-31 0:39:23 0 [Note] Plugin 'wsrep-provider' is disabled.
2025-01-31 0:39:23 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2025-01-31 0:39:23 0 [Note] InnoDB: Buffer pool(s) load completed at 250131 0:39:23
2025-01-31 0:39:25 0 [Note] Server socket created on IP: '0.0.0.0'.
2025-01-31 0:39:25 0 [Note] Server socket created on IP: '::'.
2025-01-31 0:39:25 0 [Note] mariadbd: Event Scheduler: Loaded 0 events
2025-01-31 0:39:25 0 [Note] mariadbd: ready for connections.
Version: '11.6.2-MariaDB-ubu2404' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
2025-01-31 0:43:50 3 [Warning] Aborted connection 3 to db: 'unconnected' user: 'unauthenticated' host: '139.162.70.53' (This connection closed normally without authentication)
别用提供的mysql,容器编排里面自己找一个mysql或者mariadb 的文件,
日志里面来看,容器mysql正常启动,你没有进去是因为权限没有认证,用户名和密码错误。
用户名和密码一直没有改过,这个应该不会有错的啊,我新建一个数据库试试