I followed all the steps to connect my database to my Laravel Application, including connecting to mysql using the terminal and using the connection parameters. I am able to see all of the database tables in the terminal. But, when I try to log into my application on the web, or run php artisan migrate, I get the following message: SQLSTATE[HY000] [2002] No such file or directory
SELECT * FROM users
WHERE email
= info@example.com. I am assuming this is because my database is not connected.
Here are my .env values:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testing
DB_USERNAME=username
DB_PASSWORD=protected
My app-level environment variables:
APP_NAME: App
APP_KEY: Key values
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 25060
DB_DATABASE: defaultdb
DB_USERNAME: username
DB_PASSWORD: password
APP_DEBUG: true
SSL_MODE: REQUIRED
Any help would be appreciated. Thank you.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hello @codeideas
You can try to connect to the database via terminal/shell with the
mysql
command. This will give you the opportunity to test if the login credentials are correct.Regards
Hi @codeideas,
Usually, the error is caused when you use
DB_HOST=localhost
instead ofDB_HOST=127.0.0.1
.Additionally, restart you MySQL instance and try to enter using the credetianls of your application(not sure how did you logged in to MySQL before with root or with the laravel user).