Skip to content
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

MySQL database connection refused but can access externally #4

Open
anchetaWern opened this issue Feb 12, 2022 · 5 comments
Open

MySQL database connection refused but can access externally #4

anchetaWern opened this issue Feb 12, 2022 · 5 comments

Comments

@anchetaWern
Copy link

I'm just trying out Lando for the first time using the Laravel recipe, but so far mysql is a headache. I can't seem to get it to work using this config:

name: my-lando-app
recipe: laravel
host: database
config:
  webroot: ./app/public
  via: nginx
  composer_version: '2.2.5'
  database: mysql:5.7

For context, I tried creating a database using the mysql on the host machine then exported it using table plus. Then I imported it to the lando app using lando db-import my_database.gz. I was able to connect to the database externally via tableplus by entering the following credentials:

  • db: laravel
  • username: laravel
  • password: laravel

But from within the app itself all I get is 'connection refused'. Here's my .env file:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=laravel

There weren't any privileges attached to the database (not even sure if those comes along with exports). I checked the actual export file and all it has is CREATE, DROP, and INSERT calls so it's supposed to just work without me granting privileges or anything.

Any ideas what I might be missing?

@rtfm-47 rtfm-47 transferred this issue from lando/lando Feb 12, 2022
@sinnbeck
Copy link

sinnbeck commented Feb 14, 2022

Your env is off :) https://docs.lando.dev/config/laravel.html#environment-file

DB_CONNECTION=mysql
DB_HOST=database //this as its inside docker
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=laravel

Also be aware that the root is /app on docker, so you have set your webroot to /app/app/public (unless laravel is in a subdirectory of course)

  webroot: ./public

@anchetaWern
Copy link
Author

thanks! that worked. Will now try this out on an ubuntu and windows virtual machine so we could adapt lando for our team.

@muhammadtalhaishtiaq
Copy link

Your env is off :) https://docs.lando.dev/config/laravel.html#environment-file

DB_CONNECTION=mysql
DB_HOST=database //this as its inside docker
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=laravel

Also be aware that the root is /app on docker, so you have set your webroot to /app/app/public (unless laravel is in a subdirectory of course)

  webroot: ./public

Its not working for me, I have used this same method but getting error
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')

Please guide. Thanks

@muhammadtalhaishtiaq
Copy link

thanks! that worked. Will now try this out on an ubuntu and windows virtual machine so we could adapt lando for our team.

Could you please share your solution here for help. Thanks.

@QasimMughal05
Copy link

I am on MAMP. I Just changed the port to 8889 and the password to root. It works
php artisan config:cache
php artisan cache:clear
php artisan migrate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants