Connect to Docker MySQL container from localhost?

前端 未结 7 2297
孤街浪徒
孤街浪徒 2020-11-29 23:24

I have a docker mysql image running, following is what the docker-compose.yml file looks like:

db:
  image: mysql
  environment:
    MYSQL_ROOT_PASSWORD: \"\         


        
7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 00:09

    Your yml file looks good.

    You can directly connect docker container directly as it already mapped with local port 3306. Just goto terminal and run

    mysql -h 127.0.0.1 -u root -p
    

    Note: you must have access to mysql command line. If mysql command show an error, check '/usr/local/mysql/bin' other wise you can not connect to mysql server. In other word you must have mysql client on your machine.

提交回复
热议问题