This question is tagged with mysql docker
~ Asked on 2014-04-23 03:47:28
Remember that you will need to connect to running docker container. So you probably want to use tcp instead of unix socket. Check output of docker ps command and look for running mysql containers. If you find one then use mysql command like this: mysql -h 127.0.0.1 -P <mysql_port> (you will find port in docker ps output). If you can't find any running mysql container in docker ps output then try docker images to find mysql image name and try something like this to run it: docker run -d -p 3306:3306 tutum/mysql where "tutum/mysql" is image name found in docker images.
~ Answered on 2014-05-05 11:59:55
I had the same problem, in fact, I juste forgot to run the service after installation ..
Start mysql server :
/etc/init.d/mysql start~ Answered on 2017-03-15 13:25:21
When I try to run mysql command through bash, I get this error.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")
This is my docker-compose file
db: image: mariadb:10.0.34 volumes: - ./latest_dump.sql:/docker-entrypoint-initdb.d/latest_dump.sql restart: always ports: - "3307:3306" environment: MYSQL_ROOT_PASSWORD: *******
How can I solve this issue?
From the error message, I can only assume you're using the mysql client from your host and trying to connect it to localhost. The mysql client has a special case where it converts a hostname of localhost to the default Unix socket path instead, hence the error you're seeing. Swap localhost for 127.0.0.1 and it'll probably work.
In the future, these sorts of questions/requests would be more appropriately posted to the Docker Community Forums, the Docker Community Slack, or Stack Overflow.
letanthang, nakarimi, ArturFortunato, MRROOX, and umarmughal824 reacted with thumbs up emojirodgomesc, simonjcarr, faouziMohamed, and umarmughal824 reacted with hooray emojiiltoga, xrysanthos, aadiene, james868198, simonjcarr, bernardobarreto, letanthang, rsegeda, faouziMohamed, and umarmughal824 reacted with heart emoji
I encountered the same problem, and I confirm, it works with host explicitly set with 127.0.0.1
mysql -u ${mariadb_username} -p${mariadb_password} -h 127.0.0.1
Thanks @tianon
From the error message, I can only assume you're using the mysql client from your host and trying to connect it to localhost. The mysql client has a special case where it converts a hostname of localhost to the default Unix socket path instead, hence the error you're seeing. Swap localhost for 127.0.0.1 and it'll probably work.
In the future, these sorts of questions/requests would be more appropriately posted to the Docker Community Forums, the Docker Community Slack, or Stack Overflow.
thanks a lot. It really worked.
I started docker mysql container and try to connect it outside docker using mysql command but got error:
$mysql-uroot-proot mysql:[Warning]Usingapassword on the command line interfacecan be
insecure. ERROR2002(HY000):Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'(2)
It's because mysql clinet will use unix socket protocol as default protocol value to connect to mysql server if not specifying protocol or host argument, but mysql docker container is listening on tcp socket.
Solution
$mysql-uroot-proot-h227.0.0.1 |
Specify IP address as host argument value in mysql command will make mysql to connect using TCP protocol instead of default unix socket.
(Note that using localhost as host argument value will still using unix socket protocol)
Or use
$mysql-uroot-proot--protocol tcp |
This command will specify protocol argument explicitly
Post Views: 6