try to change DB_HOST to host.docker.internal
DB_HOST=host.docker.internal
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've just spun up a new laravel 8 instance and have decided on sail/ docker as the local development environment.
Whilst I have got the site up, when I try to run migrations I get the following error:
SQLSTATE[HY000] [1044] Access denied for user 'sail'@'%' to database 'my_database' (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')
I have the following in my .env
DB_CONNECTION=mysql
DB_HOST=mariadb
DB_PORT=3306
DB_DATABASE= my_database
DB_USERNAME=sail
DB_PASSWORD=password
Any suggestions what the default is?
BTW I'm on m1 Mac so have switched to mariadb.
mariadb:
image: 'mariadb'
ports:
- '${FORWARD_DB_PORT:-3308}:3306'
environment:
MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
MYSQL_DATABASE: '${DB_DATABASE}'
MYSQL_USER: '${DB_USERNAME}'
MYSQL_PASSWORD: '${DB_PASSWORD}'
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- 'sailmysql:/var/lib/mysql'
networks:
- sail
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"]
retries: 3
timeout: 5s
any suggestions on what I can do to resolve this?
Please or to participate in this conversation.