when I used to run the following in an AWS EC2 instance after downloading latest image of mysql it always used to work.
docker run --name docker-mysql -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=urooj -e MYSQL_USER=user -e MYSQL_PASSWORD=password -d mysql:latest --default-authentication-plugin=mysql_native_password
docker exec -it docker-mysql mysql -u user -ppassword
But when I tried it this time the container docker-mysql keeps exiting just after few seconds. I tried to add -t, -i, -it in the run command but it didn't help.
Does anyone has any idea as to what went wrong?
You can check the logs of the container even after it has exited using the following command:
docker logs docker-mysql
You will then notice the error message indicating that there is no such variable default-authentication-plugin=mysql_native_password
.
2024-08-16T10:50:10.011721Z 0 [ERROR] [MY-000067] [Server] unknown variable 'default-authentication-plugin=mysql_native_password'.
To fix this, simply remove the problematic parameter and recreate the container using the following commands:
docker rm docker-mysql
docker run --name docker-mysql -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=urooj -e MYSQL_USER=user -e MYSQL_PASSWORD=password -d mysql:latest
Please note that when you create a Docker container with mysql:latest
, it uses the latest version of the image, which may be updated from time to time
For information on the default-authentication-plugin
setting, you can refer to this question as well : unknown variable 'default-authentication-plugin=mysql_native_password'
By the way, the issue is not related to AWS EC2 itself. Some Docker images may require a specific architecture to run, but that is not the case here.