Install PHP 7.4 PDO driver for PostgreSQL on Centos 7.6 - postgresql

I get the error from PDO when trying to connect to PostgreSQL:
Database Connection Error: could not find driver
I ran command to install driver:
yum install php7.4-pgsql
systemctl restart httpd
Still did not work. I found another possible driver:
yum install php72w-pdo
systemctl restart httpd
Still did not work. Checking phpinfo() page does not show PDO driver for PostgreSQL installed, and checking has no output for pgsql.
php -m | grep pgsql
I also tried installing PostgreSQL on the server, but I don't think I need since the connection is remote server. I also tried other tutorials but most are for PHP 5 and not for PHP 7.4. They said use command:
yum install php-pgsql
But this command will give me error for package conflict and list of required:
Error: Package: php-pgsql-5.4.16-48.el7.x86_64 (base)
Requires: php-pdo(x86-64) = 5.4.16-48.el7
Installed: php-pdo-7.4.11-1.el7.remi.x86_64 (#remi-php74)
php-pdo(x86-64) = 7.4.11-1.el7.remi
Available: php-pdo-5.4.16-48.el7.x86_64 (base)
php-pdo(x86-64) = 5.4.16-48.el7
...
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
However, I don't think these options should be necessary for Centos 7.4, PHP 7.4.
I can connect from MacOs development environment, but not from the Centos server.
What should I do to install the driver for PDO PostgreSQL?

Turns out I had multiple versions of PHP enabled.
Here is solution to disable all except for the one you want:
php -v
PHP 7.4.24 (cli) (built: Sep 21 2021 11:23:11) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
Check which version you are running (example 7.4)
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable remi-php74
Then install is easy:
yum install php-pdo_pgsql
systemctl restart httpd

Related

How to install mysqlclient in SLES 12?

I tried installing libmysqlclient18 package but when I do mysql -u root -p
I get If 'mysql' is not a typo you can use command-not-found to lookup the package that contains it, like this: cnf mysql
I am running MySQL server in a docker container to which I want to connect using a MySQL-client from my local machine
Please note that I just want to install mysql-client and not the mysql-server
Try using sudo yum install mysql-community-server-client
The libmysqlclient18 package is a package of some shared libraries used by most mysql packages, but not the actual client.
SLES 12 SP5 using zypper:
zypper install mysql-devel
For SLES 12 SP 5 with the SDK repo installed, you can get the MySQL client with zypper install mysql-client.

Problem installing PostgreSQL 12 on CentOS 8

Installing PostgreSQL 12:
sudo dnf install #postgresql:12
Then, contrib package for additional features: sudo dnf install postgresql-contrib
Afterwards, when I try to initialize the PostgreSQL database:
sudo postgresql-setup initdb
I'm getting: sudo: postgresql-setup: command not found
Also, when I try to check the status:
sudo systemctl status postgresql
Getting this error: Unit postgresql.service could not be found.
What I'm doing wrong? If this way of installing is wrong, is there another option to install postgresql on centos?
You have only installed the PostgreSQL client application on your server. In order to install the server software, you need to install the postgresql-server package which will satisfy those package dependencies. Afterwards you can follow this documentation to continue provisioning, configuring, and maintaining your new database.
https://www.postgresql.org/download/linux/redhat/
This gist of which, as you originally mentioned, is simply:
postgresql-setup initdb
systemctl enable postgresql.service --now

How to install PostgeSQL 11 on AWS Amazon Linux AMI 2?

I want to install PostgreSQL 11 on an EC2 instance, based on the Amazon Linux AMI 2 image. Following posts, SO questions, and finding the latest Postgresl yum repository, I tried:
sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
I get this error:
--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-4.noarch
--> Finished Dependency Resolution
Error: Package: pgdg-redhat-repo-42.0-4.noarch (/pgdg-centos11-11-2.noarch)
Requires: /etc/redhat-release
I'm stuck.. is there a clean way to overcome this problem?
Aman,
It may help you: https://stackoverflow.com/a/55883490/7541412
Moreover, if you think PostgreSQL v10 can resolve your issues. You can try these commands:
sudo yum update -y
sudo amazon-linux-extras enable postgresql10
After having PostgreSQL in your repository, now you can install:
yum clean metadata
yum install postgresql
Thanks!
I successfully installed 11.5 on Amazon Linux using
sudo amazon-linux-extras install postgresql11
I had issues with the Amazon Linux 2 AMI for CodeBuild using Python 3 but amazon-linux-extras only using Python 2 (totally bizarre considering Python 2 has been sunset, I know). From this thread you can copy the amazon_linux_extras from the Python 2 site-packages to the Python 3 one.
To find the location of amazon-linux-extras use
find -type d -name "amazon_linux_extras" # note the underscore (_), not dash (-)
To find the Python 3 site-packages directory
find -type d -name "site-packages"
To copy across
cp -r /path/to/amazon_linux_extras /path/to/python3/site-packages
Once I had done that, I used #Hassan's answer to upgrade to PostgreSQL 11.
You can install PostgreSQL by running the following command:
$ sudo yum install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs
Out of curiosity why are you not using PostgreSQL on AWS RDS?

Uninstall older unixODBC completely and install 2.3.2 unixODBC in redhat 6.3

I am trying to install msodbcsql v13 in redhat 6.3. It shows dependency error for unixODBC(64 bit) >= 2.3.1 needs to be installed before installing msodbcsql.
I tried running below command,
odbcinst -j
It shows unixODBC 2.3.2 is installed.
Also i tried to some other way,
yum provides /usr/lib64/odbcinst.so.2.0.0
The above command shows, ODBC version 2.2 is installed.
Also if i run yum local install, it shows unixODBC 32 bit version available in machine.
To remove unixODBC, i tried the below commands. But not works out.
yum remove unixODBC
yum erase unixODBC
rpm -e unixODBC*
rpm rpm -qa | grep unixODBC
I want to remove all unixODBC available in the machine. And reinstall the actual version which we required.
Manual Installation
Remove any older installed version of unixODBC (for example, unixODBC 2.2.11). On Red Hat Enterprise Linux 5 or 6, execute the following command: yum remove unixODBC. On SUSE Linux Enterprise, zypper remove unixODBC.
Go to http://www.unixodbc.org. Click the Download link on the left side of the page to go to the download page. Then click the appropriate link to save the file unixODBC-2.3.0.tar.gz to your computer. UnixODBC-2.3.1 is not supported with this release of the Microsoft ODBC Driver 11 for SQL Server.
On your Linux computer, execute the command: tar xvzf unixODBC-2.3.0.tar.gz.
Change to the unixODBC-2.3.0 directory.
At a command prompt, execute the command: CPPFLAGS="-DSIZEOF_LONG_INT=8".
At a command prompt, execute the command: export CPPFLAGS.
At a command prompt, execute the command: "./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --enable-gui=no --enable-drivers=no --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE".
At a command prompt (logged in as root), execute the command: make.
At a command prompt (logged in as root), execute the command: make install.
For additional info - visit the site
To remove all unixODBC related packages, run:
sudo yum remove unixODBC*
To install newer version of unixODBC, try to install unixODBC-utf16 package.
Here are the suggested commands:
curl -s https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/msprod.repo
sudo yum update
sudo yum info unixODBC*
sudo yum install unixODBC-utf16
See also: Install the SQL Server command-line tools on Linux.
If above won't help, check: How to install Microsoft Drivers for PHP for SQL Server on Amazon Linux AMI.

To make things right, you must install php_mongo module

I am not able to install the php mongo driver in a VPS. I've followed this and this documentantion
I checked this stack here but i can't figure out what I am doing wrong.
The VPS runs on PLESK 12 and CentOS 7.
lets say that I have the domain "mydomain.com" on my plesk and in mydomain.com/info.php a phpinfo script.
PHP INFO
PHP.ini
What amb I doing wrong?
The weird thing is that when I run the command "php -v" I get this output:
Which is not the version that is showing phpInfo.
Finally, I can't install the newest driver versions using pecl because I get the following error:
I would appreciate any help
Thanks!!
It's happens because you are call native OS binaries of php and pecl.
Plesk's PHP 5.6 binaries are stored in /opt/plesk/php/5.6/bin/. So you have to call /opt/plesk/php/5.6/bin/php and /opt/plesk/php/5.6/bin/pecl
Here full steps how to install mongodb for PHP 5.6:
[root#cos71x64-plesk12 ~]# /opt/plesk/php/5.6/bin/pecl install mongodb
/opt/plesk/php/5.6/bin/phpize not found. Run 'yum install plesk-php56-devel' to install it
[root#cos71x64-plesk12 ~]# yum install plesk-php56-devel
[root#cos71x64-plesk12 ~]# /opt/plesk/php/5.6/bin/pecl install mongodb
Build process completed successfully
Installing '/opt/plesk/php/5.6/lib64/php/modules/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.1.4
configuration option "php_ini" is not set to php.ini location
You should add "extension=mongodb.so" to php.ini
[root#cos71x64-plesk12 ~]# echo "extension=mongodb.so" > /opt/plesk/php/5.6/etc/php.d/mongodb.ini
[root#cos71x64-plesk12 ~]# /opt/plesk/php/5.6/bin/php --info | grep mongo
/opt/plesk/php/5.6/etc/php.d/mongodb.ini,
mongodb
mongodb support => enabled
mongodb version => 1.1.4
mongodb stability => stable
libmongoc version => 1.3.3
mongodb.debug => no value => no value