Quantcast
Channel: Redino blog
Viewing all articles
Browse latest Browse all 80

mysql docker connection error: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’

$
0
0

I started docker mysql container and try to connect it outside docker using mysql command but got error:

$ mysql -uroot -proot

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (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 -h127.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

The post mysql docker connection error: Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ appeared first on Redino blog.


Viewing all articles
Browse latest Browse all 80

Trending Articles