sameersbn / docker-mysql

A Dockerfile that installs a mysql server
MIT License
246 stars 174 forks source link

Cannot get into the docker "Can't connect" #26

Open samaimia opened 8 years ago

samaimia commented 8 years ago

Trying to get a shell in the docker using

docker run -it --rm --volumes-from=mysql sameersbn/mysql:latest mysql -uroot

causes

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
smoebody commented 8 years ago

are you shure your docker-container named "mysql" is running as well as the mysqld-service inside the container?

sameersbn commented 8 years ago

@samaimia

If you have set a password for the root user, this should work

docker run -it --rm --link mysql sameersbn/mysql:latest mysql -hmysql -uroot -p

else try

docker exec -it mysql mysql -uroot
jssnull commented 7 years ago

I had the same Issue installing mysql in my own dockerfile, here is a solution: http://stackoverflow.com/questions/1673530/error-2003-hy000-cant-connect-to-mysql-server-on-127-0-0-1-111 Maybe the best approach would be running a script for commenting the bind-address line in my.cnf file using CMD in the Dockerfile.