Created
August 20, 2024 08:24
-
-
Save dharma017/3ead52967ba0b95aafcaf0041f415b09 to your computer and use it in GitHub Desktop.
Connecting a Database to a Docker Container Running a Laravel Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create mysql user and grant permission | |
CREATE USER 'laraveluser'@'%' IDENTIFIED BY 'passwordhere'; | |
GRANT ALL PRIVILEGES ON dbname.* TO 'laraveluser'@'%'; | |
FLUSH PRIVILEGES; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#To get the IP address of your machine on a macOS system, run | |
ifconfig | grep "inet " | |
``` | |
inet 127.0.0.1 netmask 0xff000000 | |
inet 192.168.0.10 netmask 0xffffff00 broadcast 192.168.0.255 | |
inet 10.15.132.164 --> 10.15.132.164 netmask 0xffffffff | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update .env file | |
DB_CONNECTION=mysql | |
DB_HOST=192.168.0.10 | |
DB_PORT=3306 | |
DB_DATABASE=dbname | |
DB_USERNAME=laraveluser | |
DB_PASSWORD=passwordhere |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment