我正在使用php 7.2.2和mysql 8.0.
当我尝试连接正确的凭据时,我收到此错误:
PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]")
Run Code Online (Sandbox Code Playgroud)
需要帮助来解决问题.
实际上我正在使用以下 docker-compose.yml 文件
version: '3.3'
services:
postgres:
container_name: postgres
image: postgres:latest
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
volumes:
- ./data/postgres/pgdata:/var/lib/postgresql/data/pgdata
Run Code Online (Sandbox Code Playgroud)
我也在 docker-compose.yml 文件的同一目录中使用了这个 .env 文件:
POSTGRES_USER=dbadm
POSTGRES_PASSWORD=dbpwd
POSTGRES_DB=db
Run Code Online (Sandbox Code Playgroud)
然后我以这种方式将 bash shell 运行到容器中:
docker exec -ti postgres bash
Run Code Online (Sandbox Code Playgroud)
在此之后调用命令:
psql -h postgres -U dbadm db
Run Code Online (Sandbox Code Playgroud)
我得到错误:
psql: FATAL: password authentication failed for user "dbadm"
Run Code Online (Sandbox Code Playgroud)
奇怪的事实是,如果使用默认图像参数:
psql -h postgres -U admin database
Run Code Online (Sandbox Code Playgroud)
并插入默认密码“password”,它让我登录,似乎忽略了环境变量。
我错过了什么?
来自 docker-compose up 日志的其他日志:
postgres | 2017-10-15 09:19:15.502 UTC [1] …Run Code Online (Sandbox Code Playgroud) 我正在使用这个官方的 php Docker 镜像:https : //github.com/docker-library/php/blob/76a1c5ca161f1ed6aafb2c2d26f83ec17360bc68/7.1/alpine/Dockerfile
现在我需要添加对 yaml 扩展的支持,它没有与 php 捆绑在一起。我看到我使用的基本图像使用了 phpize。
我正在尝试这种方法:
FROM php:7.1.5-alpine
# Install and enable yaml extension support to php
RUN apk add --update yaml yaml-dev
RUN pecl channel-update pecl.php.net
RUN pecl install yaml-2.0.0 && docker-php-ext-enable yaml
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
running: phpize
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' …Run Code Online (Sandbox Code Playgroud) docker ×2
php ×2
alpine-linux ×1
dockerfile ×1
mysql ×1
pdo ×1
phpize ×1
postgresql ×1
psql ×1