PhpStorm - How to connect to MySQL via Docker2019 Community Moderator ElectionConnect to Docker MySQL container from localhost?How do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?Reference - What does this error mean in PHP?How is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersCopying files from host to Docker containerFrom inside of a Docker container, how do I connect to the localhost of the machine?

PTIJ: How can I halachically kill a vampire?

Do f-stop and exposure time perfectly cancel?

Why doesn't this Google Translate ad use the word "Translation" instead of "Translate"?

My story is written in English, but is set in my home country. What language should I use for the dialogue?

Am I not good enough for you?

Fourth person (in Slavey language)

Examples of a statistic that is not independent of sample's distribution?

Reverse string, can I make it faster?

Adding an additional "order by" column gives me a much worse plan

Why is there a voltage between the mains ground and my radiator?

Is there an elementary proof that there are infinitely many primes that are *not* completely split in an abelian extension?

How strictly should I take "Candidates must be local"?

Should I take out a loan for a friend to invest on my behalf?

What Happens when Passenger Refuses to Fly Boeing 737 Max?

Virginia employer terminated employee and wants signing bonus returned

Is "history" a male-biased word ("his+story")?

Do Bugbears' arms literally get longer when it's their turn?

Who deserves to be first and second author? PhD student who collected data, research associate who wrote the paper or supervisor?

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

How much stiffer are 23c tires over 28c?

Moving plot label

Why the color red for the Republican Party

Replacing Windows 7 security updates with anti-virus?

"One can do his homework in the library"



PhpStorm - How to connect to MySQL via Docker



2019 Community Moderator ElectionConnect to Docker MySQL container from localhost?How do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?Reference - What does this error mean in PHP?How is Docker different from a virtual machine?Should I use Vagrant or Docker for creating an isolated environment?How to list containers in DockerHow to get a Docker container's IP address from the host?How to remove old Docker containersCopying files from host to Docker containerFrom inside of a Docker container, how do I connect to the localhost of the machine?










0















I am working with PhpStorm 2018.3.4, Docker, MySQL and Ubuntu.
I tried unsuccessfully to configure MySQL with the Docker container network_mysql.



First, I have tried this configuration :



First configuration



It gave me this error :



Result of the first configuration



Then, I tried this :



Second configuration



This one gave me this other error.



Result of the second configuration



Am I missing something? Is there another place where I must configure something?



docker ps output :



docker ps



Here docker network ls :



docker network ls



For the command docker inspect network_mysql, here is a link to the description :
https://pastebin.com/9LmeAkc8



Here is a docker-compose.yml configuration :
https://pastebin.com/DB4Eye4y



I tried to put - "3306:3306" in addition to the wex_server_proxy section with no avail.



The file to modify was this one :



https://pastebin.com/TPBQNCDZ



I added the ports section, opening the 3306 port :) And then, it works.










share|improve this question
























  • use your mysql container name in connection host

    – Muhammad Hamza Younas
    Mar 6 at 16:21











  • you can see the container name by this command docker ps or docker container ls

    – Muhammad Hamza Younas
    Mar 6 at 16:23











  • typo mysql:/// three slashes, should be 2 ?

    – Alex
    Mar 6 at 16:26











  • Can you share your container configuration?

    – Nico Haase
    Mar 6 at 16:26











  • Possible duplicate of Connect to Docker MySQL container from localhost?

    – Nico Haase
    Mar 6 at 16:27















0















I am working with PhpStorm 2018.3.4, Docker, MySQL and Ubuntu.
I tried unsuccessfully to configure MySQL with the Docker container network_mysql.



First, I have tried this configuration :



First configuration



It gave me this error :



Result of the first configuration



Then, I tried this :



Second configuration



This one gave me this other error.



Result of the second configuration



Am I missing something? Is there another place where I must configure something?



docker ps output :



docker ps



Here docker network ls :



docker network ls



For the command docker inspect network_mysql, here is a link to the description :
https://pastebin.com/9LmeAkc8



Here is a docker-compose.yml configuration :
https://pastebin.com/DB4Eye4y



I tried to put - "3306:3306" in addition to the wex_server_proxy section with no avail.



The file to modify was this one :



https://pastebin.com/TPBQNCDZ



I added the ports section, opening the 3306 port :) And then, it works.










share|improve this question
























  • use your mysql container name in connection host

    – Muhammad Hamza Younas
    Mar 6 at 16:21











  • you can see the container name by this command docker ps or docker container ls

    – Muhammad Hamza Younas
    Mar 6 at 16:23











  • typo mysql:/// three slashes, should be 2 ?

    – Alex
    Mar 6 at 16:26











  • Can you share your container configuration?

    – Nico Haase
    Mar 6 at 16:26











  • Possible duplicate of Connect to Docker MySQL container from localhost?

    – Nico Haase
    Mar 6 at 16:27













0












0








0








I am working with PhpStorm 2018.3.4, Docker, MySQL and Ubuntu.
I tried unsuccessfully to configure MySQL with the Docker container network_mysql.



First, I have tried this configuration :



First configuration



It gave me this error :



Result of the first configuration



Then, I tried this :



Second configuration



This one gave me this other error.



Result of the second configuration



Am I missing something? Is there another place where I must configure something?



docker ps output :



docker ps



Here docker network ls :



docker network ls



For the command docker inspect network_mysql, here is a link to the description :
https://pastebin.com/9LmeAkc8



Here is a docker-compose.yml configuration :
https://pastebin.com/DB4Eye4y



I tried to put - "3306:3306" in addition to the wex_server_proxy section with no avail.



The file to modify was this one :



https://pastebin.com/TPBQNCDZ



I added the ports section, opening the 3306 port :) And then, it works.










share|improve this question
















I am working with PhpStorm 2018.3.4, Docker, MySQL and Ubuntu.
I tried unsuccessfully to configure MySQL with the Docker container network_mysql.



First, I have tried this configuration :



First configuration



It gave me this error :



Result of the first configuration



Then, I tried this :



Second configuration



This one gave me this other error.



Result of the second configuration



Am I missing something? Is there another place where I must configure something?



docker ps output :



docker ps



Here docker network ls :



docker network ls



For the command docker inspect network_mysql, here is a link to the description :
https://pastebin.com/9LmeAkc8



Here is a docker-compose.yml configuration :
https://pastebin.com/DB4Eye4y



I tried to put - "3306:3306" in addition to the wex_server_proxy section with no avail.



The file to modify was this one :



https://pastebin.com/TPBQNCDZ



I added the ports section, opening the 3306 port :) And then, it works.







mysql docker phpstorm






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 15:07







lionelp

















asked Mar 6 at 16:20









lionelplionelp

369




369












  • use your mysql container name in connection host

    – Muhammad Hamza Younas
    Mar 6 at 16:21











  • you can see the container name by this command docker ps or docker container ls

    – Muhammad Hamza Younas
    Mar 6 at 16:23











  • typo mysql:/// three slashes, should be 2 ?

    – Alex
    Mar 6 at 16:26











  • Can you share your container configuration?

    – Nico Haase
    Mar 6 at 16:26











  • Possible duplicate of Connect to Docker MySQL container from localhost?

    – Nico Haase
    Mar 6 at 16:27

















  • use your mysql container name in connection host

    – Muhammad Hamza Younas
    Mar 6 at 16:21











  • you can see the container name by this command docker ps or docker container ls

    – Muhammad Hamza Younas
    Mar 6 at 16:23











  • typo mysql:/// three slashes, should be 2 ?

    – Alex
    Mar 6 at 16:26











  • Can you share your container configuration?

    – Nico Haase
    Mar 6 at 16:26











  • Possible duplicate of Connect to Docker MySQL container from localhost?

    – Nico Haase
    Mar 6 at 16:27
















use your mysql container name in connection host

– Muhammad Hamza Younas
Mar 6 at 16:21





use your mysql container name in connection host

– Muhammad Hamza Younas
Mar 6 at 16:21













you can see the container name by this command docker ps or docker container ls

– Muhammad Hamza Younas
Mar 6 at 16:23





you can see the container name by this command docker ps or docker container ls

– Muhammad Hamza Younas
Mar 6 at 16:23













typo mysql:/// three slashes, should be 2 ?

– Alex
Mar 6 at 16:26





typo mysql:/// three slashes, should be 2 ?

– Alex
Mar 6 at 16:26













Can you share your container configuration?

– Nico Haase
Mar 6 at 16:26





Can you share your container configuration?

– Nico Haase
Mar 6 at 16:26













Possible duplicate of Connect to Docker MySQL container from localhost?

– Nico Haase
Mar 6 at 16:27





Possible duplicate of Connect to Docker MySQL container from localhost?

– Nico Haase
Mar 6 at 16:27












1 Answer
1






active

oldest

votes


















2














Solution



I notice that you are not mapping the mysql container port out. If you did, you would see this from the docker ps command:



... 0.0.0.0:3306->3306/tcp network_mysql


Post not mapped out for mysql container



The container network_mysql is attached to a bridge type network called tmp_wex_net. This means that the container is not accesible from the host, by it's container name.



I appears that you are using a docker-compose.yml definition for the stack. In order to be able to access the container from the host, you need to use the ports section of your compose definition for this container:



serivces:
mysql:
...
ports:
- "3306:3306"
...


If you are starting it with docker run, then you can acomplish the same thing with:



docker run -p 3306:3306 --name network_mysql --network="tmp_wex_net" -d mysql


And then use localhost in the hostname of your connection settings in PHPStorm. Like this:




Host: localhost



Port: 3306



Database: network





The problem



The reason that you are not able to connect, is that the host name network_mysql that you specify in the connection settings, does not resolve to any host that your machines knows of.



The container name of a docker container, is not a DNS name that the docker host can resolve.



If you have not specified any network for your mysql container, then it is connected to the default bridge network. And if you have created a new network, without specifying the type - it will also default to the bridge driver.



In order to access the container from the host, you need to either:



  1. Connect the container to the host network

  2. Or from a container on a bridge network, map the port to the host like suggested in the solution above. You can then address the specifically mapped port on that container with localhost:<portnum> from the host machine.





share|improve this answer

























  • I added the docker inspect network_mysql command via a link in my original post.

    – lionelp
    Mar 7 at 9:34











  • I can see that your container is in the 'tmp_wex_net' network which is a bridge network. Please try my instructions in the bottom of my answer. I think I will move them to the top.

    – Andreas Lorenzen
    Mar 7 at 9:49












  • I edited my answer to fit the new information, and to make the solution appear in the top of the answer. Let me know if the suggested solution works out for you.

    – Andreas Lorenzen
    Mar 7 at 10:18











  • I will discuss of your solution with the one who created the overlay.

    – lionelp
    Mar 7 at 11:32











  • I changed something to the Docker configuration file (that i just added to my post) but it did not change anything.

    – lionelp
    Mar 7 at 14:19











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027706%2fphpstorm-how-to-connect-to-mysql-via-docker%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














Solution



I notice that you are not mapping the mysql container port out. If you did, you would see this from the docker ps command:



... 0.0.0.0:3306->3306/tcp network_mysql


Post not mapped out for mysql container



The container network_mysql is attached to a bridge type network called tmp_wex_net. This means that the container is not accesible from the host, by it's container name.



I appears that you are using a docker-compose.yml definition for the stack. In order to be able to access the container from the host, you need to use the ports section of your compose definition for this container:



serivces:
mysql:
...
ports:
- "3306:3306"
...


If you are starting it with docker run, then you can acomplish the same thing with:



docker run -p 3306:3306 --name network_mysql --network="tmp_wex_net" -d mysql


And then use localhost in the hostname of your connection settings in PHPStorm. Like this:




Host: localhost



Port: 3306



Database: network





The problem



The reason that you are not able to connect, is that the host name network_mysql that you specify in the connection settings, does not resolve to any host that your machines knows of.



The container name of a docker container, is not a DNS name that the docker host can resolve.



If you have not specified any network for your mysql container, then it is connected to the default bridge network. And if you have created a new network, without specifying the type - it will also default to the bridge driver.



In order to access the container from the host, you need to either:



  1. Connect the container to the host network

  2. Or from a container on a bridge network, map the port to the host like suggested in the solution above. You can then address the specifically mapped port on that container with localhost:<portnum> from the host machine.





share|improve this answer

























  • I added the docker inspect network_mysql command via a link in my original post.

    – lionelp
    Mar 7 at 9:34











  • I can see that your container is in the 'tmp_wex_net' network which is a bridge network. Please try my instructions in the bottom of my answer. I think I will move them to the top.

    – Andreas Lorenzen
    Mar 7 at 9:49












  • I edited my answer to fit the new information, and to make the solution appear in the top of the answer. Let me know if the suggested solution works out for you.

    – Andreas Lorenzen
    Mar 7 at 10:18











  • I will discuss of your solution with the one who created the overlay.

    – lionelp
    Mar 7 at 11:32











  • I changed something to the Docker configuration file (that i just added to my post) but it did not change anything.

    – lionelp
    Mar 7 at 14:19
















2














Solution



I notice that you are not mapping the mysql container port out. If you did, you would see this from the docker ps command:



... 0.0.0.0:3306->3306/tcp network_mysql


Post not mapped out for mysql container



The container network_mysql is attached to a bridge type network called tmp_wex_net. This means that the container is not accesible from the host, by it's container name.



I appears that you are using a docker-compose.yml definition for the stack. In order to be able to access the container from the host, you need to use the ports section of your compose definition for this container:



serivces:
mysql:
...
ports:
- "3306:3306"
...


If you are starting it with docker run, then you can acomplish the same thing with:



docker run -p 3306:3306 --name network_mysql --network="tmp_wex_net" -d mysql


And then use localhost in the hostname of your connection settings in PHPStorm. Like this:




Host: localhost



Port: 3306



Database: network





The problem



The reason that you are not able to connect, is that the host name network_mysql that you specify in the connection settings, does not resolve to any host that your machines knows of.



The container name of a docker container, is not a DNS name that the docker host can resolve.



If you have not specified any network for your mysql container, then it is connected to the default bridge network. And if you have created a new network, without specifying the type - it will also default to the bridge driver.



In order to access the container from the host, you need to either:



  1. Connect the container to the host network

  2. Or from a container on a bridge network, map the port to the host like suggested in the solution above. You can then address the specifically mapped port on that container with localhost:<portnum> from the host machine.





share|improve this answer

























  • I added the docker inspect network_mysql command via a link in my original post.

    – lionelp
    Mar 7 at 9:34











  • I can see that your container is in the 'tmp_wex_net' network which is a bridge network. Please try my instructions in the bottom of my answer. I think I will move them to the top.

    – Andreas Lorenzen
    Mar 7 at 9:49












  • I edited my answer to fit the new information, and to make the solution appear in the top of the answer. Let me know if the suggested solution works out for you.

    – Andreas Lorenzen
    Mar 7 at 10:18











  • I will discuss of your solution with the one who created the overlay.

    – lionelp
    Mar 7 at 11:32











  • I changed something to the Docker configuration file (that i just added to my post) but it did not change anything.

    – lionelp
    Mar 7 at 14:19














2












2








2







Solution



I notice that you are not mapping the mysql container port out. If you did, you would see this from the docker ps command:



... 0.0.0.0:3306->3306/tcp network_mysql


Post not mapped out for mysql container



The container network_mysql is attached to a bridge type network called tmp_wex_net. This means that the container is not accesible from the host, by it's container name.



I appears that you are using a docker-compose.yml definition for the stack. In order to be able to access the container from the host, you need to use the ports section of your compose definition for this container:



serivces:
mysql:
...
ports:
- "3306:3306"
...


If you are starting it with docker run, then you can acomplish the same thing with:



docker run -p 3306:3306 --name network_mysql --network="tmp_wex_net" -d mysql


And then use localhost in the hostname of your connection settings in PHPStorm. Like this:




Host: localhost



Port: 3306



Database: network





The problem



The reason that you are not able to connect, is that the host name network_mysql that you specify in the connection settings, does not resolve to any host that your machines knows of.



The container name of a docker container, is not a DNS name that the docker host can resolve.



If you have not specified any network for your mysql container, then it is connected to the default bridge network. And if you have created a new network, without specifying the type - it will also default to the bridge driver.



In order to access the container from the host, you need to either:



  1. Connect the container to the host network

  2. Or from a container on a bridge network, map the port to the host like suggested in the solution above. You can then address the specifically mapped port on that container with localhost:<portnum> from the host machine.





share|improve this answer















Solution



I notice that you are not mapping the mysql container port out. If you did, you would see this from the docker ps command:



... 0.0.0.0:3306->3306/tcp network_mysql


Post not mapped out for mysql container



The container network_mysql is attached to a bridge type network called tmp_wex_net. This means that the container is not accesible from the host, by it's container name.



I appears that you are using a docker-compose.yml definition for the stack. In order to be able to access the container from the host, you need to use the ports section of your compose definition for this container:



serivces:
mysql:
...
ports:
- "3306:3306"
...


If you are starting it with docker run, then you can acomplish the same thing with:



docker run -p 3306:3306 --name network_mysql --network="tmp_wex_net" -d mysql


And then use localhost in the hostname of your connection settings in PHPStorm. Like this:




Host: localhost



Port: 3306



Database: network





The problem



The reason that you are not able to connect, is that the host name network_mysql that you specify in the connection settings, does not resolve to any host that your machines knows of.



The container name of a docker container, is not a DNS name that the docker host can resolve.



If you have not specified any network for your mysql container, then it is connected to the default bridge network. And if you have created a new network, without specifying the type - it will also default to the bridge driver.



In order to access the container from the host, you need to either:



  1. Connect the container to the host network

  2. Or from a container on a bridge network, map the port to the host like suggested in the solution above. You can then address the specifically mapped port on that container with localhost:<portnum> from the host machine.






share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 7 at 10:13

























answered Mar 6 at 23:14









Andreas LorenzenAndreas Lorenzen

881212




881212












  • I added the docker inspect network_mysql command via a link in my original post.

    – lionelp
    Mar 7 at 9:34











  • I can see that your container is in the 'tmp_wex_net' network which is a bridge network. Please try my instructions in the bottom of my answer. I think I will move them to the top.

    – Andreas Lorenzen
    Mar 7 at 9:49












  • I edited my answer to fit the new information, and to make the solution appear in the top of the answer. Let me know if the suggested solution works out for you.

    – Andreas Lorenzen
    Mar 7 at 10:18











  • I will discuss of your solution with the one who created the overlay.

    – lionelp
    Mar 7 at 11:32











  • I changed something to the Docker configuration file (that i just added to my post) but it did not change anything.

    – lionelp
    Mar 7 at 14:19


















  • I added the docker inspect network_mysql command via a link in my original post.

    – lionelp
    Mar 7 at 9:34











  • I can see that your container is in the 'tmp_wex_net' network which is a bridge network. Please try my instructions in the bottom of my answer. I think I will move them to the top.

    – Andreas Lorenzen
    Mar 7 at 9:49












  • I edited my answer to fit the new information, and to make the solution appear in the top of the answer. Let me know if the suggested solution works out for you.

    – Andreas Lorenzen
    Mar 7 at 10:18











  • I will discuss of your solution with the one who created the overlay.

    – lionelp
    Mar 7 at 11:32











  • I changed something to the Docker configuration file (that i just added to my post) but it did not change anything.

    – lionelp
    Mar 7 at 14:19

















I added the docker inspect network_mysql command via a link in my original post.

– lionelp
Mar 7 at 9:34





I added the docker inspect network_mysql command via a link in my original post.

– lionelp
Mar 7 at 9:34













I can see that your container is in the 'tmp_wex_net' network which is a bridge network. Please try my instructions in the bottom of my answer. I think I will move them to the top.

– Andreas Lorenzen
Mar 7 at 9:49






I can see that your container is in the 'tmp_wex_net' network which is a bridge network. Please try my instructions in the bottom of my answer. I think I will move them to the top.

– Andreas Lorenzen
Mar 7 at 9:49














I edited my answer to fit the new information, and to make the solution appear in the top of the answer. Let me know if the suggested solution works out for you.

– Andreas Lorenzen
Mar 7 at 10:18





I edited my answer to fit the new information, and to make the solution appear in the top of the answer. Let me know if the suggested solution works out for you.

– Andreas Lorenzen
Mar 7 at 10:18













I will discuss of your solution with the one who created the overlay.

– lionelp
Mar 7 at 11:32





I will discuss of your solution with the one who created the overlay.

– lionelp
Mar 7 at 11:32













I changed something to the Docker configuration file (that i just added to my post) but it did not change anything.

– lionelp
Mar 7 at 14:19






I changed something to the Docker configuration file (that i just added to my post) but it did not change anything.

– lionelp
Mar 7 at 14:19




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027706%2fphpstorm-how-to-connect-to-mysql-via-docker%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

Алба-Юлія

Захаров Федір Захарович