I cannot get PHP to connect to PGSQL. I am running Mavericks 10.9.4. Here are the steps I followed:
Figured out where default PHP w/ mac was living (which php)
rmdir that directory
brew install php54
php -v shows new php 5.4
php -m shows no pdo_pgsql module
brew install php54-pdo-pgsql
php -m show pdo_pgsql module
php -ishows the following info
.
PDO support => enabled
PDO drivers => mysql, odbc, sqlite, pgsql
pdo_mysql
PDO Driver for MySQL => enabled
Client API version => mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $
Directive => Local Value => Master Value
pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock
PDO_ODBC
PDO Driver for ODBC (unixODBC) => enabled
ODBC Connection Pooling => Enabled, strict matching
pdo_pgsql
PDO Driver for PostgreSQL => enabled
PostgreSQL(libpq) Version => 9.4.4
Module version => 1.0.2
Revision => $Id: 8e4cc97fb53f418d98b489c3e9d722e48446e676 $
Open /usr/local/etc/php/5.4/php.ini and add extension=pgsql.so, then save
sudo apachectl restart
Open phpinfo() page
PDO drivers section only shows mysql, sqlite
Loaded Configuration File section shows php.ini same file w/ the pgsql extension
Also whenever I run a php command in console I see
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php54/5.4.43_2/lib/php/extensions/no-debug-non-zts-20100525/pgsql.so' - dlopen(/usr/local/Cellar/php54/5.4.43_2/lib/php/extensions/no-debug-non-zts-20100525/pgsql.so, 9): image not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php54/5.4.43_2/lib/php/extensions/no-debug-non-zts-20100525/pgsql.so' - dlopen(/usr/local/Cellar/php54/5.4.43_2/lib/php/extensions/no-debug-non-zts-20100525/pgsql.so, 9): image not found in Unknown on line 0
Related
Running a DigitalOcean droplet on Ubuntu (20.4?)
I have userA with root permission. They are also connected to userA within the postgres db.
Due to the setup for the software I'm using, they require a specific username for the postgresdb. Just so I'm not exposing too much data online, we'll call that userB. That's both a linux and postgres user.
I'm running a php command that basically takes (uname, dbname, pdo, options) as input, and it's currently failing bc it can't locate the pdo file.
I've looked through a few posts. One suggested to uncomment all of the pgsql and pdo_pgsql lines in all of the php.ini files, which i've done, both for production, development, and the generic version of that file.
When I run the command as both userA and userB I get this error.
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/lib/php/20190902/pdo_pgsql (/usr/lib/php/20190902/pdo_pgsql: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_pgsql.so (/usr/lib/php/20190902/pdo_pgsql.so: undefined symbol: pdo_parse_params)) in Unknown on line 0
However, pdo_pgsql.so actually does exist in that location. (is it looking for a file just named pdo_pgsql and is instead finding pdo_pgsql.so?)
The php site says to run a
./configure
command, but it doesn't really say which folder configure is in. It's not a package I can install from cli. (https://www.php.net/manual/en/ref.pdo-pgsql.php)
Other pages say you have to install autoconf first (https://unix.stackexchange.com/questions/158960/can-not-run-configure-command-no-such-file-or-directory) however that has not made ./configure an available command for me.
I've also found a post saying that a conf file in apache needs to be updated to show the location of the PDO file, however I'm not yet running a server, I'm just running a php file that populates a pgsql db locally. (pgsql extension is not loading)
Running
php -i | grep PDO
gives
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/lib/php/20190902/pdo_pgsql (/usr/lib/php/20190902/pdo_pgsql: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_pgsql.so (/usr/lib/php/20190902/pdo_pgsql.so: undefined symbol: pdo_parse_params)) in Unknown on line 0
PDO
PDO support => enabled
PDO drivers => pgsql
PDO Driver for PostgreSQL => enabled
Though according to customer service from the API it should be returning
PDO
PDO support => enabled
PDO drivers => mysql, odbc, pgsql
PDO Driver for MySQL => enabled
PDO Driver for ODBC (unixODBC) => enabled
PDO Driver for PostgreSQL => enabled
Though I think they're giving multiple examples of different drivers depending on your db software of choice.
I'm not exactly sure what to do.
Update:
I've tried editing the php.ini file that is being used by php via
php -i | grep ini
I used
locate pdo_pgsql
to find the pdo_pgsql and pdo_pgsql.so filepaths. I have tried 4 different edits to the php.ini file. 2 being uncommenting (one at a time) the default pgsql extensions. 2 being different filepaths to the pdo_pgsql files that are found on my system through locate.
**extension=/usr/lib/php/20190902/pdo_pgsql.so**
sudo php file.php
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20190902/pdo_pgsql.so' (tried: /usr/lib/php/20190902/pdo_pgsql.so (/usr/lib/php/20190902/pdo_pgsql.so: **undefined symbol: pdo_parse_params**), /usr/lib/php/20190902//usr/lib/php/20190902/pdo_pgsql.so.so (/usr/lib/php/20190902//usr/lib/php/20190902/pdo_pgsql.so.so: **cannot open shared object file: No such file or directory**)) in Unknown on line 0
**extension=/var/lib/php/modules/7.4/registry/pdo_pgsql**
sudo php file.php
PHP Warning: PHP Startup: Unable to load dynamic library '/var/lib/php/modules/7.4/registry/pdo_pgsql' (tried: /var/lib/php/modules/7.4/registry/pdo_pgsql (/var/lib/php/modules/7.4/registry/pdo_pgsql: **file too short**), /usr/lib/php/20190902//var/lib/php/modules/7.4/registry/pdo_pgsql.so (/usr/lib/php/20190902//var/lib/php/modules/7.4/registry/pdo_pgsql.so: **cannot open shared object file: No such file or directory)**) in Unknown on line 0
Could not open input file: file.php
**extension=pgsql**
sudo php file.php
**PHP Warning: Module 'pgsql' already loaded in Unknown on line 0**
Could not open input file: file.php
**extension=pdo_pgsql**
sudo php file.php
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/lib/php/20190902/pdo_pgsql (/usr/lib/php/20190902/pdo_pgsql: **cannot open shared object file: No such file or directory**), /usr/lib/php/20190902/pdo_pgsql.so (/usr/lib/php/20190902/pdo_pgsql.so: **undefined symbol: pdo_parse_params**)) in Unknown on line 0
Could not open input file: file.php
output as requested by user below
$ php -v
PHP 7.4.3 (cli) (built: Mar 2 2022 15:36:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
$ dpkg -l|grep pgsql
ii php-pgsql 2:7.4+75 all PostgreSQL module for PHP [default]
ii php7.4-pgsql 7.4.3-4ubuntu2.10 amd64 PostgreSQL module for PHP
$ dpkg -l|grep php
ii php-common 2:75 all Common files for PHP packages
ii php-pgsql 2:7.4+75 all PostgreSQL module for PHP [default]
ii php7.4-cli 7.4.3-4ubuntu2.10 amd64 command-line interpreter for the PHP scripting language
ii php7.4-common 7.4.3-4ubuntu2.10 amd64 documentation, examples and common module for PHP
ii php7.4-json 7.4.3-4ubuntu2.10 amd64 JSON module for PHP
ii php7.4-opcache 7.4.3-4ubuntu2.10 amd64 Zend OpCache module for PHP
ii php7.4-pgsql 7.4.3-4ubuntu2.10 amd64 PostgreSQL module for PHP
ii php7.4-readline 7.4.3-4ubuntu2.10 amd64
If something does not work on your DEV enc, do not TRY it on the PROD.. this beats the purpose of having a DEV env..
in php.ini you should already have an example on how to enable pgsql:
extension=pdo_pgsql
not module=
I do not see what is your PHP version, but make sure you install the appropriate version of php7.X-pgsql as it seems you have the wrong version of the library..
You can maybe add to your question the output of:
dpkg -l|grep pgsql
dpkg -l|grep php
php -v
When I ask the drush status while im in the folder of the website I get this message
/volume1/web/drupal8 $ drush status
PHP Fatal error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in
phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php on line 56
Fatal error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in
phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php on line 56
Drush command terminated abnormally due to an unrecoverable error.
[error] Error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in
phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php, line 56
When I ask the drush status while im in the bin folder drush seem to work
/bin$ drush status PHP configuration : /etc/php/php.ini PHP OS
: Linux Drush script : /usr/local/bin/drush Drush
version : 8.1.5 Drush temp directory : /tmp Drush
configuration : Drush alias files :
I can't figure out what im doing wrong, how can I run drush on folder /volume1/web/drupal8?
thanks in advance
PDO is installed and enabled. I run php56 -i
PDO PDO support => enabled PDO drivers => dblib, mysql, pgsql, sqlite
pdo_dblib
PDO Driver for FreeTDS/Sybase DB-lib => enabled Flavour => freetds
pdo_mysql
PDO Driver for MySQL => enabled Client API version => mysqlnd
5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd 41fc93cccd5bac2fe7a $
Directive => Local Value => Master Value pdo_mysql.default_socket =>
/run/mysqld/mysqld.sock => /run/mysqld/mysqld.sock
pdo_pgsql
PDO Driver for PostgreSQL => enabled PostgreSQL(libpq) Version =>
9.3.6 Module version => 1.0.2 Revision => $Id: 0e858dd2051ca8c2fd3c781909a0670ab5fecd36 $ pdo_sqlite
PDO Driver for SQLite 3.x => enabled SQLite Library => 3.10.2
Probably, you don't have properly installed PDO_MYSQL. You need to invoke phpinfo() function and see if this module is present. The constant MYSQL_ATTR_SSL_CA comes from PDO library. If php is invoked from CLI then probably it has its own php.ini so you need to enable PDO there as well.
To check if you have enabled PDO in PHP CLI run php -m |grep PDO the command should return PDO string.
To install PDO check the PHP Manual for Installing PDO.
I face this issue as well on all drupal 7 and 8 directory, while drush works fine outside drupal, it doesn't work in Drupal directory. the error says:
Error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in Drush\Sql\Sqlmysql->creds() (line 56 of phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php).
Installing php-mysql (or php5-mysql) fix the issue.
I have installed the module with php ( ./configure --with-pdo-pgsql=/var/lib/postgresql/9.3/main), but I obtain one more time the same error: Fatal error: Call to undefined function pg_connect(). In my configuration file of php, php.ini, the postgresql pdo_pgsql module appears as loaded:
pdo_pgsql
---------
PDO Driver for PostgreSQL enabled
PostgreSQL(libpq) Version 9.3.4
Module version 1.0.2
Revision $Id$
pdo_pgsql is the PostgreSQL driver for PDO.
If you need pg_connect, you should install the PostgreSQL extension.
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
I am trying to update the schema of mysql database by doctorine
php app/console doctrine:schema:update --force
it shows
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar/php/5.3.10/lib/php/extensions/no-debug-non-zts-20090626/php_pdo_mysql.dll' - dlopen(/usr/local/Cellar/php/5.3.10/lib/php/extensions/no-debug-non-zts-20090626/php_pdo_mysql.dll, 9): image not found in Unknown on line 0
[PDOException]
could not find driver
it looks like extension is not available.
but according to my phpinfo();
pdo_mysql is enabled.
pdo_mysql
PDO Driver for MySQL enabled
Client API version mysqlnd 5.0.10 - 20111026 - $Id: e707c415db32080b3752b232487a435ee0372157 $
Directive Local Value Master Value
pdo_mysql.default_socket /tmp/mysql.sock /tmp/mysql.sock
Is there any other point to check for me?
I also tried comment or uncomment this line in php.ini
;extension=php_pdo_mysql.dll
thanks a lot.
You're using php in CLI, which may not be configured the same way as php, the module of your webserver.
This means that if you want information about php CLI, you should try php -i in cli, not request a script with a call to phpinfo(). More simply, to check which modules are loaded in CLI, run php -m.
And also, to know which ini files are loaded in CLI, use php --ini.