-
-
Notifications
You must be signed in to change notification settings - Fork 654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Howto]: Connect laravel in docker with MySQL on host OS #919
Comments
@wcaaan I am confused here. If your Host Mysql is running on port |
I tried it with 3307 as well. it does not connect. |
I tried it with 3307 as well. it does not connect. Are you implying that this configuration is right and only port is wrong ? if that's the case it means there is something else wrong. |
@wcaaan did you set |
i tried both. |
@wcaaan Remove Now set your host's MySQL to some random port like Then set Laravel's If still having issues, please provide the log file of Laravel or Laravel screenshot error. |
okay thankyou will check and get back to you. |
Here is what id did 1: There are no containers running so i removed the 2: I changed the port of my 3: Now i set 4: now i ran this command 5: now i open laravel application try to connect and it say 6: The laravel log file inside Any suggestion ?? |
I even tried this as well, in |
@wcaaan, you can do one thing. In the host's Mysql, Instead of |
I checked my IP in
This time it given me this error which may lead to something.
|
How do i make this sure |
@wcaaan check this to slow the |
Okay, @vikas5914 I really appreciate your help, time and guidance. This is how i did it, the application is CONNECTED 😄 but there is still one problem 😟 and i cannot figure out. Why 1: 2: I removed the 3: I changed the port of my 4: In order to connect from
5: Restarted the MySQL server and confirmed that MySQL can now listen to all IP's and NOT just localhost 6: use this command
7: Once its confirmed that 8: In mysql shell execute these quesies, since I'm using
9: To make sure the
10: Now its time to
Note: my 11: To find out your local IP on MAC go to The thing I'm concerned about is that my local IP keep changing, and as per the documentation |
@wcaaan I think it is easier to get a static local IP. You google for Router and How to set a Static IP for the MAC address. I also have a question. Why are you using MySQL from the Devilbox? |
okay, I'll google it, but that i not the permenant solution to the problem, if the doucmentation says that |
@wcaaan Try this, ping My note: You should look and try to upgrade the database so the majority can be used on the same version. At least try to make it so that you will need only two different MySQL versions. That is more possible than running different kinds of MySQL versions at once. |
Again as usual an error.
|
Inside the docker, run this: |
|
Try |
it does not work, the only thing it works with is internal IP of my host machine, which keeps changing and I'm sick of this now, I think i'll try laradock or some other custom stack. |
I have added So the host system is available via this address: |
Have you already checked elsewhere?
What are you struggling with?
OS / ENVIRONMENT:
Host operating system and version: MacOS Monterey 12.5.1
Docker desktop version: 4.12.0 (85629)
Docker desktop engine: Engine: 20.10.17
Docker desktop compose version: v2.10.2
I'm trying to connect the laravel app inside docker with MySQL on my host machine.
What have you tried already?
On my host machine MySQL is running is connected with following credentials.
Host OS MySQL
MySQL version: 8.0.27
Host: 127.0.0.1
Port: 3307
Password: No password
** Devilbox .env file:**
Expose MySQL Port to Host
HOST_PORT_MYSQL=3306
Laravel .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=hanger
DB_USERNAME=root
DB_PASSWORD=
If i run
docker-compose up -d php httpd mysql
everything work fine i'm able to connect to database via devilbox phpmyadmin.As per the documentation https://devilbox.readthedocs.io/en/latest/corporate-usage/use-external-databases.html#database-on-host-os i ran this command
docker-compose up -d php httpd bind
but i unable to connect to the database from inside the docker to host OS MySQL.What is your goal?
I want to connect the laravel app in docker with MySQL on my host machine.
The text was updated successfully, but these errors were encountered: