sameersbn / docker-mysql

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

why it not work? #11

Closed sunlingfeng-daren closed 9 years ago

sunlingfeng-daren commented 9 years ago

Dear sir: I use this command docker run -i -t --rm --link mysql:db sameersbn/mysql mysql -uroot -h db,it show errors: ERROR 1045 (28000): Access denied for user 'root'@'10.0.0.28' (using password: NO); when I use this :docker run -i -t --rm --volumes-from=mysql sameersbn/mysql mysql -uroot, I can login to use mysql console.

I want to know what is different between two commands? thks!

sameersbn commented 9 years ago

@sunlingfeng-daren you need to add --volumes-from=mysql, not --link mysql:db

sunlingfeng-daren commented 9 years ago

Dear sir: can u tell me why I must use --volumes-from=mysql? Thanks!

sameersbn commented 9 years ago

@sunlingfeng-daren That is because in the mysql -uroot command you are not specifying the mysql server hostname or port. By default the mysql client will try to connect to the unix socket of the mysql server.

The --volumes-from mysql volume mounts the socket directory of the mysql server container inside the client container, thereby making the unix socket available in the client container. As a result, the mysql client can connect to the mysql server using the unix socket

sunlingfeng-daren commented 9 years ago

I see. thanks for your help!