I am learning Laravel and migrations. I have installed Homestead successfully and everything is be up and running — MySQL included — until I give my first
php artisan migrate
and the shell outputs
[PDOException]
could not find driver
so I connect to the virtual machine via SSH and try to install the PHP extensions required to work with the database, but apt-get detects I have the latest driver version already installed. Then I check to see if PDO is working, so I type php -i | grep PDO and everything looks good:
PDO
PDO support => enabled
PDO drivers => mysql, pgsql, sqlite
PDO Driver for MySQL => enabled
PDO Driver for PostgreSQL => enabled
PDO Driver for SQLite 3.x => enabled
I am out of ideas, what could possibly go wrong?
Related
I am facing a strange error with laravel under ubuntu using PostgreSql.
Its NOT a PDOException. The database migration is successful so all driver are set and PDO connection is also established. But why this error?
Didn't find much about it in google. I am attaching the screenshot.
This is NOT homestead rather own lamp stack.
Edit:
There is no problem even with tinker
Regards
I resolved this issue using the following command:-
sudo apt install php7.4-pgsql (replace 7.4 with your php version)
To check PHP version use: php -v
For more info visit: https://www.php.net/manual/en/pgsql.installation.php
Please check php info and serach "PDO Driver for PostgreSQL" or "pdo_pgsql" after run the above command
keywords :- for pgadmin, pgsql, postgresql, PDO Driver for PostgreSQL, pdo_pgsql #vasimraja
Please check the default key in app/config/database.php
For postgres, default should be 'default' => 'postgres',
I've been trying to add the Firebird extension to PDO with no luck. I have a RHEL7 server, I ran ./configure --with-firebird successfully, ran the make command, and make install successfully.
If I type
php -i | grep PDO
I get the following:
PDO
PDO support => enabled
PDO drivers => firebird, sqlite
PDO_Firebird
PDO Driver for Firebird/InterBase => enabled
PDO Driver for SQLite 3.x => enabled
However, when going to my site's phptest.php file it only shows
mysql
sqlite
I guess I'm missing one last step, but I don't know what.
Try running slightly different command
./configure --with-firebird --with-pdo-firebird
Then find phph.ini (or the file that acts like that in Linux platform) and enable (de-comment?) the line like extension=php_pdo_firebird.dll ( in Linux it probably would be like libphp_pdo_firebird.so or something, see for the specific files your building process generate).
See also:
http://php.net/manual/en/ref.pdo-firebird.php
Enable PHP Firebird connection
I have just started learning PHP and Mysql and I have a problem when I run php file.
error :could not find driver
This is version that I am using:
I tried to follow answers of question that similar but still can not solve the problem.
It appears you have a simple typographical error in your code. You defined your DSN with the string msql:dbhost=localhost...
But you should use mysql:dbhost=localhost...
See http://php.net/manual/en/ref.pdo-mysql.connection.php for reference docs on the MySQL DSN format.
You have installed php-pdo but you might also need either php-mysql or php-mysqlnd (prefer the latter).
You can check by running php -i | less to give a lengthy report of all the extensions currently installed. Look for the "PDO" section, and confirm that the mysql driver is among the drivers installed:
PDO
PDO support => enabled
PDO drivers => sqlite, mysql, sqlite2
If it does, it should be followed by a "pdo_mysql" section. Mine looks like this:
pdo_mysql
PDO Driver for MySQL => enabled
Client API version => mysqlnd 5.0.8-dev - 20102224 - $Id: 731e5b87ba42146a687c29995d2dfd8b4e40b325 $
Directive => Local Value => Master Value
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock
If you don't have the pdo_mysql section, you should install the corresponding yum package for it:
sudo yum install php-mysqlnd
I've configured pdo_informix:
[root#cc-allplus nginx]# php -i |egrep "pdo|PDO"
PDO
PDO support => enabled
PDO drivers => sqlite, sqlite2, odbc, pgsql, informix, dblib
pdo_dblib
PDO Driver for FreeTDS/Sybase DB-lib => enabled
pdo_informix
pdo_informix support => enabled
PDO_ODBC
PDO Driver for ODBC (unixODBC) => enabled
pdo_pgsql
PDO Driver for PostgreSQL => enabled
Revision => $Id: pdo_pgsql.c 300351 2010-06-10 12:11:19Z iliaa $
pdo_sqlite
PDO Driver for SQLite 3.x => enabled
and trying out to create connection :
try{
$dbh = new PDO ("informix:host=some.example.ru; service=50000; database=test; server=test_net; protocol=onsoctcp;DB_LOCALE=en_US.57372; CLIENT_LOCALE=en_US.57372;", "dcs_test", "********");
}catch (PDOException $e){
echo 'Failed to execute your db connection: '. $e->getMessage().'</br>'; exit;
}
And the response is :
Failed to execute your db connection: SQLSTATE=HY000, SQLSetConnectAttr: -11097 [Informix][Informix ODBC Driver]Optional feature not implemented
Googling not helped with resolving this issue.. any suggesions are welcome
Problem was solved.
For those who might stuck with the same troubles with informix or others pdo's libraries I would like to share.
My trouble was in choosing the latest version of PDO_INFORMIX soursec. As I searched and discovered, php 5.3 need informix not later than 1.2.6 version.
I discovered that information from an article in Hungarian language, and it was the only post about such incompatibility between php and PDO_INFORMIX in whole www.
Not any string of such info at IBM site, nor at pdo PECL sources site.. God, that take me a few days, but I did it!
After I found right version I had to recompile the php, cause it have put 1.3.0 version of informix pdo in cache and didn't want to work with older one.
Hope that would help!
I'm using zend framework, and I have to connect to a microsoft sql db 2005. I've installed all the needed packages through the packet manager (homebrew) following (this tutorial), I've successfully downloaded the version of php5.5 with pdo_dblib. Then the problem started.
Is the php installation valid for Zend framework and zend studio too? Since, the error that I was getting when trying to connect to the db hasn't changed at all so there must be a mistake;
When I run:
php -i | grep -i pdo
The output is:
API Extensions => mysqli,pdo_mysql,mysql
PDO
PDO support => enabled
PDO drivers => mysql, sqlite
pdo_mysql
PDO Driver for MySQL => enabled
pdo_mysql.default_socket => /var/mysql/mysql.sock => /var/mysql/mysql.sock
pdo_sqlite
PDO Driver for SQLite 3.x => enabled
So, where is my new installation with php 5.5 and pdo-dblib and mssql?
I'm quite confused...
PS: I'm running OSX 10.9
I've found a tutorial which explains how to link the new version of php. Specifically what is interesting of it is in those two lines of code:
nano ~/.bash_profile
export PATH="$(brew --prefix josegonzalez/php/php55)/bin:/usr/local/bin:$PATH"
now the command:
php -i | grep -i pdo
gives the following output (with pdo dblib):
API Extensions => mysqli,pdo_mysql,mysql
PDO
PDO support => enabled
PDO drivers => dblib, mysql, odbc, sqlite
pdo_dblib
PDO Driver for FreeTDS/Sybase DB-lib => enabled
pdo_mysql
PDO Driver for MySQL => enabled
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock
PDO_ODBC
PDO Driver for ODBC (unixODBC) => enabled
pdo_sqlite
PDO Driver for SQLite 3.x => enabled