Connect to mysql in a docker container from the host

后端 未结 14 822
青春惊慌失措
青春惊慌失措 2020-11-29 16:25

(It\'s probably a dumb question due to my limited knowledge with Docker or mysql administration, but since I spent a whole evening on this issue, I dare to ask it.)

14条回答
  •  难免孤独
    2020-11-29 16:44

    run following command to run container

    docker run --name db_name -e MYSQL_ROOT_PASSWORD=PASS--publish 8306:3306 db_name
    

    run this command to get mysql db in host machine

    mysql -h 127.0.0.1 -P 8306 -uroot  -pPASS
    

    in your case it is

    mysql -h 127.0.0.1 -P 12345 -uroot  -pPASS
    

提交回复
热议问题