我有这个用于在docker中配置MySQL的yml文件:
# Use root/example as user/password credentials
version: '3.1'
services:
db:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'pass'
MYSQL_DATABASE: 'db'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'pass'
adminer:
image: adminer
restart: always
ports:
- 8888:8080
我使用yml所在的同一目录中的以下命令启动容器:
docker-compose -f stack.yml up
然后我收到了这个错误:
答案 0 :(得分:5)
这对我有用:
image: mysql:5.7
答案 1 :(得分:2)
如果遇到此错误,但仍希望使用MySQL v.8。您可以通过告诉MySQL服务器使用旧版身份验证插件来做到这一点。
因此,您的撰写文件将如下所示:
# Use root/example as user/password credentials
version: '3.1'
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_ROOT_PASSWORD: 'pass'
MYSQL_DATABASE: 'db'
MYSQL_USER: 'user'
MYSQL_PASSWORD: 'pass'
adminer:
image: adminer
restart: always
ports:
- 8888:8080
答案 2 :(得分:1)
由于我刚刚花了最后3个小时来寻找这个同一问题的解决方案,所以我想我会继续介绍Hatef的答案。将命令docker rm $(docker ps -a -q)
docker volume prune -f
添加到容器中可以运行,但是您必须首先运行以下命令集:
Write-Host 'Begin configuring MySQL Server'
$server = @{
name = 'testdb';
mysql_database = 'test';
mysql_user = 'test';
mysql_pass = '';
mysql_root_pass = '';
mysql_port = '3306';
mysql_version = 'latest';
adminer_port = '8080';
adminer_version = 'latest';
};
$stackFilePath = '.\stack.yml';
if (Test-Path $stackFilePath)
{
Write-Host 'Cleaning up old configuration file'
Remove-Item $stackFilePath
}
$stack = @"
version: '3.7'
services:
mysql:
image: mysql:$($server.mysql_version)
container_name: $($server.name)-mysql
command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_ROOT_PASSWORD=$($server.mysql_root_pass)
- MYSQL_DATABASE=$($server.mysql_database)
- MYSQL_USER=$($server.mysql_user)
- MYSQL_PASSWORD=$($server.mysql_pass)
- MYSQL_PORT=$($server.mysql_port)
- MYSQL_ALLOW_EMPTY_PASSWORD=true
restart: always
ports:
- $($server.mysql_port):$($server.mysql_port)
expose:
- $($server.mysql_port)
adminer:
image: adminer:$($server.adminer_version)
container_name: $($server.name)-adminer
depends_on:
- mysql
restart: always
ports:
- $($server.adminer_port):8080
"@;
Write-Host 'Writing new configuration file'
$stack | Out-File -FilePath $stackFilePath
Write-Host 'Clean up old processes'
docker rm $(docker ps -a -q)
Write-Host 'Clean up old volumes'
docker volume prune -f
Write-Host 'Create service from configurations'
docker-compose -f $stackFilePath up
这是因为在不清理容器的情况下(是的,标记为退出的容器),并非所有的卷都将被修剪。而且,如果您不修剪所有卷,则该数据库将从先前实例中保留下来。这令人迷惑,因为容器被认为是隔离的实例,但是如果卷在它们之间仍然存在则不会。
请注意,这可以解决phpmyadmin和任何其他基于php的mysql维护工具中的相同消息。
为了使事情变得容易,我编写了一个powershell脚本来处理清理两次安装之间的进程/卷。
pandas