title: How to connect to mysql created by docker-compose
body: <p>I can not connect to Mysql created with Docker in local environment (Mac OS X).
  <br>
  I have created the following configuration file.</p>
  
  <pre><code>version: '2'
  services:
    db:
      image: mysql:5.7
      environment:
        MYSQL_DATABASE: mysqldatabase
        MYSQL_USER: mysql
        MYSQL_PASSWORD: mysql
        MYSQL_ROOT_PASSWORD: password
      ports:
        - "33333:3306"
      container_name: mysql-db
      volumes:
        - db-data:/var/lib/mysql
  
  volumes:
    db-data:
      driver: local
  </code></pre>
  
  <p>Then, I started the docker container of mysql with the following command.</p>
  
  <pre><code>$ docker-compose up -d
  $ docker start mysql-db
  </code></pre>
  
  <p>Up to this point there was no problem, but an error occurred when trying to connect to mysql.</p>
  
  <pre><code>$ mysql -p 33333 -u root -p
  Enter password: 
  ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
  </code></pre>
  
  <p>Please tell me how to deal with it.</p>