I'm using the official MySQL image from docker hub and expose ports 3333:3306 to connect from outside.
I know that I have to change the bind IP inside
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'container_ip';
mysql -h container_ip -u root -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Hmm I'm a little confused. From the point of view of the host os, the docker container is bound to one or more network interfaces on the host os. In your compose file you are exposing port 3333 to the host. That's what you have to connect to.
Plus you need to use an IP address, otherwise the mysql client will try to connect with a unix socket.
mysql -h 127.0.0.1 --port 3333 -u root -p
If you are trying to connect from inside your blog container then you can use mysqldb as your host with the 3306 port.