Could not find driver for postgres using laradock - php

I am using the laradock and Postgres in my laravel project but when I try to run PHP artisan migrate it gives me the error, could not find the driver. below is my .env file
DB_CONNECTION=pgsql
DB_HOST=postgres
DB_PORT=5432
DB_DATABASE=vv
DB_USERNAME=default
DB_PASSWORD=secret
When I run my project it fetches the data, but when I try to migrate it give the error, driver could not find and show me the error on this connection file,
laravel/framework/src/Illuminate/Database/Connection.php:671
Note: when I use MySQL it works fine, but when I use Postgres it gives me this error, and my postgres image on docker is working fine. My pgadmin connects to postgres

Related

How do I connect Laravel Sail to a MySQL GUI?

I am using Laravel Sail/ Docker for the first time. I have got my site running fine but the issue is that I cannot access the DB via a GUI (Sequel Pro). I have added the default credentials from my env but cannot access. But seem to be able to run php artisan migrate. Does anybody have any tips for how I can debug this?
This is my .env file:
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=my-db
DB_USERNAME=sail
DB_PASSWORD=password
The solution for you might be in the last comment here by Lorenzo Franzone: changing the SequelPro version.
Rather than this though, I dropped the version of MySQL in docker-compose from 8.0 to 5.7 to work with my very old version of SQLYog and: Bingo! It worked.
Simple, you must change DB_HOST=mysql to DB_HOST=127.0.0.1
Have a good day.

php artisan migrate stuck at the beginning of the command

[MacOS 10.14.0]
When I create a new project (Laravel new blog)
Then create a table in MySQL (create database blog)
And then update my .env file with the correct userame, password and database.
After creating a project, I will run php artisan migrate
But my terminal stays empty, I can type in my terminal. But it won't do anything.
My storage/logs folder is empty.
I have 2 default migrate files in my database/migrations folder.
php migrate list works
What can it be?
For me it helped just to restart local database.
After a lot of trial and error, I found out that there was something wrong with my MySQL server. I reinstalled MySQL with brew. The latest version of 8 and the latest version of 5.7.*. Both didn't work, because of the following conflict: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 2): image not found.
So the whole time, everything in my .env file was correct but my MySQL was broken. I also confirmed that by trying to connect with the app 'Sequel Pro'. And as I thought, it gave me the same conflict.
How I fixed the problem:
Remove all MySQL/MariaDB packages via brew (if you have installed them with brew like me)
Install MySQL Community Server 5.7.* from the official mysql.com website (you can google that file).
Add MySQL to your path export PATH=$PATH:/usr/local/mysql/bin
Go to: System Preferences -> MySQL -> press 'Start MySQL Server'
Change your temporary password with a new one mysqladmin -uroot -p[temporary password] password '[new password]'
Good luck! 👍
EDIT FEBRUARY 26 2019:
I found a problem with changing the random generated password. I was using MySQL Community Server 5.7.25 and the random generated password was: _>9mxWc9a!0.. When I was trying to change the default password with the command above. I was given the following error:
-bash: !0: event not found
If you have the same error as I did or something similar, try the following:
Enter the following command in your terminal: mysqladmin -uroot -p password '[new password]'
When you press enter, it will ask you for a password. Now enter the random generated password that was given to you by the MySql Community Server at installation in a prompt.
It should be working now! 😊
If you're using Docker and getting this error on the host machine, try running the migration in the container cli.
did you connected the laravel project to the database from .env file ?
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=DATABASE_NAME
DB_USERNAME=DATABASE_USERNAME
DB_PASSWORD=DATABASE_PASSWORD
Laravel 5.8 with SQLite.
My problem wasn't with larvel but with DB browser for sqlite. I had to open and close the program for the migrate to finish its process.

Linux laravel migrate driver not found

i have a error when i running php artisan migrate. It shows could not find driver in connection.php and connector.php , any idea to fix it ?error php artisan migrate
Try checking with 127.0.0.1 and check if you have correct db configuration.

Laravel php artisan migrate connection refused

I am running Laravel 5 with PHP 7.0.6. When I run the php artisan update command, I get the following error:
[PDOException]
SQLSTATE[HY000] [2002] Connection refused
This is obviously database related. This happens on a production machine I have as well as local environment. My site is working in both environments.
Does anyone understand this error? Thanks.
You are missing the PHP-CLI database extension. Your site does work because your server is using the PHP-FPM (where you have the PHP extention of your database installed). But when you run php artisan migrate command you are actually executing it on the PHP-CLI.

PDOException SQLSTATE[HY000] [2002] No such file or directory when trying to migrate

This question has already been asked multiple times, however I can't seem to get it to work anyway.
I am trying to migrate a migration I just created with laravel to my freshly created database. However, everytime I type in php artisan migrate I'm getting the above error
PDOException SQLSTATE[HY000] [2002] No such file or directory
What I have done is the following:
Create a database and a database user
CREATE DATABASE openletter CHARACTER SET utf8;
CREATE USER 'openletter'#'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON openletter.* TO 'openletter'#'%';
Add these configs to the .env
DB_HOST=localhost
DB_DATABASE=openletter
DB_USERNAME=openletter
DB_PASSWORD=secret
Creating the migration
php artisan make:migration create_letters_table --create=letters
Migrating the migration
php artisan migrate
Then, the above listed error came.
What I tried
Restart the MySQL Service: vagrant ssh && sudo service mysqld restart
Reloading Homestead/Vagrant: vagrant reload --provision
Setting the database config in config/database.php
Many people telling others to link the mysql socket, but those people are refferencing MAMP or XAMPP or sth. else. I'm however using Homestead
What could also be the problem?
Ok guys, I fixed the issue. I'm an idiot and should be ashamed. The reason it didn't work, was because I wasn't in my vagrant machine.
After doing vagrant ssh navigating to my project cd work/OpenLetter and doing php artisan migrate it worked of course.

Categories