How to connect to ProxySQL with default config on Docker

2.1k Views Asked by At

I installed docker, got the most popular box with proxySQL.

docker run -d -p 6032:6032 --name proxysql prima/proxysql:latest

then I tried to connect to it from my local mysql like so:

mysql -u admin -padmin -h 127.0.0.1 -P6032

and I'm getting this error:

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0 "Internal error/check (Not system error)"

I tried this trick with twindb/proxysql:latest and prima/proxysql:latest docker images and the result was the same :(

2

There are 2 best solutions below

2
On BEST ANSWER

You need to map 6033 instead of 6032

docker run -d 6033:6033 --name proxysql prima/proxysql:latest

And then run below

mysql -u admin -padmin -h 127.0.0.1 -P6033

Inside the container mysql listens on 127.0.0.1:6032 and for outside connections it listens on 0.0.0.0:6033. So you need to use 6033 for connections from outside the container

1
On

You cannot connect to proxysql from outside the container in default config. bash into the proxysql container and then execute

 mysql -u admin -p<password-here> -h 127.0.0.1 -P 6032 --prompt='proxysql>'

default password will be the admin