Skip to content

Instantly share code, notes, and snippets.

@dharma017
Created August 20, 2024 08:24
Show Gist options
  • Save dharma017/3ead52967ba0b95aafcaf0041f415b09 to your computer and use it in GitHub Desktop.
Save dharma017/3ead52967ba0b95aafcaf0041f415b09 to your computer and use it in GitHub Desktop.
Connecting a Database to a Docker Container Running a Laravel Project
# Create mysql user and grant permission
CREATE USER 'laraveluser'@'%' IDENTIFIED BY 'passwordhere';
GRANT ALL PRIVILEGES ON dbname.* TO 'laraveluser'@'%';
FLUSH PRIVILEGES;
#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
```
# 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