无法使用 Adminer 和 docker-compose 连接到 MySQL 数据库
Can't Connect to MySQL Database using Adminer and docker-compose
我正在尝试使用来自 docker 中心的官方 adminer
和 mysql
图像连接到我的 mysql 数据库。
这是我的 docker-compose.yml
文件配置:
version: '3'
services:
mysql:
image: mysql
restart: always
volumes:
- mysql:/var/lib/mysql
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD= 1
- MYSQL_DATABASE= db
ports:
- 3306:3306
- 33060:33060
adminer:
image: adminer
restart: always
ports:
- 8080:8080
depends_on:
- mysql
volumes:
mysql:
每当我想使用 Adminer 登录 MySQL 时,我都会遇到以下问题:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
SQLSTATE[HY000] [2002] No such file or directory
这是我尝试从管理员界面连接到 MySQL 时使用的输入:
#first try
System: MySQL
Server: localhost
Username: root
Database: db
#second try
System: MySQL
Server: mysql #container-name
Username: root
Database: db
您必须在撰写文件中添加默认身份验证插件
command: --default-authentication-plugin=mysql_native_password
这里是完整的docker-compose.yml
services:
mysql:
image: mysql
restart: always
command: --default-authentication-plugin=mysql_native_password
volumes:
- mysql:/var/lib/mysql
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD= 1
- MYSQL_DATABASE= db
ports:
- 3306:3306
- 33060:33060
adminer:
image: adminer
restart: always
ports:
- 8080:8080
depends_on:
- mysql
volumes:
mysql:
在管理员中
System: MySQL <DB System to connect>
Server: mysql <should match the starting tag before image tag > (in your case mysql but you can change it to any name )
Username: root <username>
Password: <password>
Database: db <database name>
我正在尝试使用来自 docker 中心的官方 adminer
和 mysql
图像连接到我的 mysql 数据库。
这是我的 docker-compose.yml
文件配置:
version: '3'
services:
mysql:
image: mysql
restart: always
volumes:
- mysql:/var/lib/mysql
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD= 1
- MYSQL_DATABASE= db
ports:
- 3306:3306
- 33060:33060
adminer:
image: adminer
restart: always
ports:
- 8080:8080
depends_on:
- mysql
volumes:
mysql:
每当我想使用 Adminer 登录 MySQL 时,我都会遇到以下问题:
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
SQLSTATE[HY000] [2002] No such file or directory
这是我尝试从管理员界面连接到 MySQL 时使用的输入:
#first try
System: MySQL
Server: localhost
Username: root
Database: db
#second try
System: MySQL
Server: mysql #container-name
Username: root
Database: db
您必须在撰写文件中添加默认身份验证插件
command: --default-authentication-plugin=mysql_native_password
这里是完整的docker-compose.yml
services:
mysql:
image: mysql
restart: always
command: --default-authentication-plugin=mysql_native_password
volumes:
- mysql:/var/lib/mysql
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD= 1
- MYSQL_DATABASE= db
ports:
- 3306:3306
- 33060:33060
adminer:
image: adminer
restart: always
ports:
- 8080:8080
depends_on:
- mysql
volumes:
mysql:
在管理员中
System: MySQL <DB System to connect>
Server: mysql <should match the starting tag before image tag > (in your case mysql but you can change it to any name )
Username: root <username>
Password: <password>
Database: db <database name>