如何解决docker-compose with adminer & mariadb 在尝试连接数据库时显示 403
过去几个小时我一直在调试我的系统,但我对这里发生的事情一无所知。
我正在使用一个简单的 docker-compose.yml
文件在我的 Ubuntu 20.04 LTS 系统上启动一个 mariadb 和一个 adminer 实例。
docker-compose.yml:
version: '3'
services:
database:
image: mariadb
restart: always
environment:
MYSQL_DATABASE: feedback
MYSQL_USER: db_user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: root
adminer:
image: adminer
restart: always
environment:
ADMINER_DEFAULT_SERVER: database
ports:
- "127.0.0.1:8080:8080"
一位同事对此进行了测试,并且 100% 的时间都可以在他们的系统上运行。但是,在我的系统上的最后几个小时内进行了多次尝试中,它只成功了两次。
这是 docker-compose 输出:
Creating knowledge-base_database_1 ... done
Creating knowledge-base_adminer_1 ... done
Attaching to knowledge-base_adminer_1,knowledge-base_database_1
database_1 | 2021-05-31 12:17:04+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.5.10+maria~focal started.
adminer_1 | [Mon May 31 12:17:04 2021] PHP 7.4.19 Development Server (http://[::]:8080) started
database_1 | 2021-05-31 12:17:04+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
database_1 | 2021-05-31 12:17:04+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.5.10+maria~focal started.
database_1 | 2021-05-31 12:17:05+00:00 [Note] [Entrypoint]: Initializing database files
database_1 |
database_1 |
database_1 | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
database_1 | To do so,start the server,then issue the following command:
database_1 |
database_1 | '/usr/bin/mysql_secure_installation'
database_1 |
database_1 | which will also give you the option of removing the test
database_1 | databases and anonymous user created by default. This is
database_1 | strongly recommended for production servers.
database_1 |
database_1 | See the MariaDB Knowledgebase at https://mariadb.com/kb or the
database_1 | MySQL manual for more instructions.
database_1 |
database_1 | Please report any problems at https://mariadb.org/jira
database_1 |
database_1 | The latest information about MariaDB is available at https://mariadb.org/.
database_1 | You can find additional information about the MySQL part at:
database_1 | https://dev.mysql.com
database_1 | Consider joining MariaDB's strong and vibrant community:
database_1 | https://mariadb.org/get-involved/
database_1 |
database_1 | 2021-05-31 12:17:06+00:00 [Note] [Entrypoint]: Database files initialized
database_1 | 2021-05-31 12:17:06+00:00 [Note] [Entrypoint]: Starting temporary server
database_1 | 2021-05-31 12:17:06+00:00 [Note] [Entrypoint]: Waiting for server startup
database_1 | 2021-05-31 12:17:06 0 [Note] mysqld (mysqld 10.5.10-MariaDB-1:10.5.10+maria~focal) starting as process 99 ...
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Uses event mutexes
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Number of pools: 1
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
database_1 | 2021-05-31 12:17:06 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Initializing buffer pool,total size = 134217728,chunk size = 134217728
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: 128 rollback segments are active.
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: 10.5.10 started; log sequence number 45118; transaction id 20
database_1 | 2021-05-31 12:17:06 0 [Note] Plugin 'FEEDBACK' is disabled.
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2021-05-31 12:17:06 0 [Note] InnoDB: Buffer pool(s) load completed at 210531 12:17:06
database_1 | 2021-05-31 12:17:06 0 [Warning] 'user' entry 'root@5315aa145a33' ignored in --skip-name-resolve mode.
database_1 | 2021-05-31 12:17:06 0 [Warning] 'proxies_priv' entry '@% root@5315aa145a33' ignored in --skip-name-resolve mode.
database_1 | 2021-05-31 12:17:06 0 [Note] Reading of all Master_info entries succeeded
database_1 | 2021-05-31 12:17:06 0 [Note] Added new Master_info '' to hash table
database_1 | 2021-05-31 12:17:06 0 [Note] mysqld: ready for connections.
database_1 | Version: '10.5.10-MariaDB-1:10.5.10+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
database_1 | 2021-05-31 12:17:07+00:00 [Note] [Entrypoint]: Temporary server started.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
database_1 | 2021-05-31 12:17:09 5 [Warning] 'proxies_priv' entry '@% root@5315aa145a33' ignored in --skip-name-resolve mode.
database_1 | 2021-05-31 12:17:09+00:00 [Note] [Entrypoint]: Creating database feedback
database_1 | 2021-05-31 12:17:09+00:00 [Note] [Entrypoint]: Creating user db_user
database_1 | 2021-05-31 12:17:09+00:00 [Note] [Entrypoint]: Giving user db_user access to schema feedback
database_1 |
database_1 | 2021-05-31 12:17:09+00:00 [Note] [Entrypoint]: Stopping temporary server
database_1 | 2021-05-31 12:17:09 0 [Note] mysqld (initiated by: root[root] @ localhost []): Normal shutdown
database_1 | 2021-05-31 12:17:09 0 [Note] Event Scheduler: Purging the queue. 0 events
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: FTS optimize thread exiting.
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Starting shutdown...
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Buffer pool(s) dump completed at 210531 12:17:09
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
database_1 | 2021-05-31 12:17:09 0 [Note] InnoDB: Shutdown completed; log sequence number 45130; transaction id 21
database_1 | 2021-05-31 12:17:09 0 [Note] mysqld: Shutdown complete
database_1 |
database_1 | 2021-05-31 12:17:10+00:00 [Note] [Entrypoint]: Temporary server stopped
database_1 |
database_1 | 2021-05-31 12:17:10+00:00 [Note] [Entrypoint]: MariaDB init process done. Ready for start up.
database_1 |
database_1 | 2021-05-31 12:17:10 0 [Note] mysqld (mysqld 10.5.10-MariaDB-1:10.5.10+maria~focal) starting as process 1 ...
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Uses event mutexes
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Number of pools: 1
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
database_1 | 2021-05-31 12:17:10 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Initializing buffer pool,chunk size = 134217728
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: 128 rollback segments are active.
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: 10.5.10 started; log sequence number 45130; transaction id 20
database_1 | 2021-05-31 12:17:10 0 [Note] Plugin 'FEEDBACK' is disabled.
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2021-05-31 12:17:10 0 [Note] InnoDB: Buffer pool(s) load completed at 210531 12:17:10
database_1 | 2021-05-31 12:17:10 0 [Note] Server socket created on IP: '::'.
database_1 | 2021-05-31 12:17:10 0 [Warning] 'proxies_priv' entry '@% root@5315aa145a33' ignored in --skip-name-resolve mode.
database_1 | 2021-05-31 12:17:10 0 [Note] Reading of all Master_info entries succeeded
database_1 | 2021-05-31 12:17:10 0 [Note] Added new Master_info '' to hash table
database_1 | 2021-05-31 12:17:10 0 [Note] mysqld: ready for connections.
database_1 | Version: '10.5.10-MariaDB-1:10.5.10+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
尝试使用 root:root 以管理员身份登录数据库会产生以下输出:
adminer_1 | [Mon May 31 12:17:54 2021] [::ffff:172.25.0.1]:38170 Accepted
adminer_1 | [Mon May 31 12:17:54 2021] [::ffff:172.25.0.1]:38170 [302]: POST /?server=database&username=root
adminer_1 | [Mon May 31 12:17:54 2021] [::ffff:172.25.0.1]:38170 Closing
adminer_1 | [Mon May 31 12:17:54 2021] [::ffff:172.25.0.1]:38174 Accepted
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38174 [403]: GET /?server=database&username=root
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38174 Closing
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38208 Accepted
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38208 [200]: GET /?file=favicon.ico&version=4.8.0
adminer_1 | [Mon May 31 12:18:24 2021] [::ffff:172.25.0.1]:38208 Closing
我尝试过禁用防火墙、重新安装 docker 和 docker-compose、使用 docker 创建自定义网络而不是使用 docker-compose 的默认网络等。
我还在我的系统上启动了一个已知的工作项目,它产生了相同的结果。我系统上的某些东西似乎坏了,但我不知道去哪里找了。
有没有人有任何想法我可以尝试使其工作?
解决方法
尝试附加 /index.php
,而不是 http://localhost
转到 http://localhost/index.php
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。