11

I have installed PHP 7, mysql5.7, Apache2.2, CentOS6.

And I'm installing CodeIgniter3.0.6.

When I use database connection, error occured and said

A PHP Error was encountered

Severity: Core Warning

Message: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/php_mysqli.so' - /usr/lib64/php/modules/php_mysqli.so: cannot open shared object file: No such file or directory

Filename: Unknown

Line Number: 0

Of course there are no files in '/usr/lib64/php/modules/php_mysqli.so', but I don't know how to install mysqli.so.

I tried

yum install php-mysql

but

Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirror.awanti.com
 * updates: ftp.iij.ad.jp
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.x86_64 0:5.3.3-46.el6_7.1 will be installed
--> Processing Dependency: php-common(x86-64) = 5.3.3-46.el6_7.1 for package: php-mysql-5.3.3-46.el6_7.1.x86_64
--> Finished Dependency Resolution
Error: Package: php-mysql-5.3.3-46.el6_7.1.x86_64 (updates)
           Requires: php-common(x86-64) = 5.3.3-46.el6_7.1
           Installed: php-common-7.0.4-1.el6.remi.x86_64 (@remi-php70)
               php-common(x86-64) = 7.0.4-1.el6.remi
           Available: php-common-5.3.3-40.el6_6.x86_64 (base)
               php-common(x86-64) = 5.3.3-40.el6_6
           Available: php-common-5.3.3-46.el6_6.x86_64 (updates)
               php-common(x86-64) = 5.3.3-46.el6_6
           Available: php-common-5.3.3-46.el6_7.1.x86_64 (updates)
               php-common(x86-64) = 5.3.3-46.el6_7.1
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

and it didn't work.


when I execute yum install php7.0-mysql or yum install php70w-mysql command,

Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirror.awanti.com
 * updates: ftp.iij.ad.jp
No package php7.0-mysql available.
Error: Nothing to do

I don't know what to do at all.

Déjà vu
  • 28,223
  • 6
  • 72
  • 100
ryochanuedasan
  • 528
  • 1
  • 6
  • 11
  • http://stackoverflow.com/questions/25872600/yum-install-php-mysql-unable-to-install-centos – Mihai Apr 03 '16 at 15:51

2 Answers2

13

For PHP7, on CentOS / RHEL:

yum install php70w-mysql

if you use the Remi repository

yum install php70-php-mysqlnd

for Ubuntu:

apt-get install php7.0-mysql
Federkun
  • 36,084
  • 8
  • 78
  • 90
  • Thank you for your comment. But , when I execute that command. ``` Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * epel: ftp.riken.jp * extras: ftp.iij.ad.jp * remi-safe: mirror.awanti.com * updates: ftp.iij.ad.jp No package php7.0-mysql available. Error: Nothing to do ``` – ryochanuedasan Apr 03 '16 at 15:34
  • Yes. `$ cat /etc/centos-release` => `CentOS release 6.7 (Final)` – ryochanuedasan Apr 03 '16 at 15:44
  • I never used remi repository -- can you try with `yum install php70-php-mysqlnd`? – Federkun Apr 03 '16 at 15:50
  • I executed that command, it seems to have been installed! `Package php70-php-mysqlnd-7.0.5-1.el6.remi.x86_64 already installed and latest version` – ryochanuedasan Apr 03 '16 at 16:18
  • if it has installed, why isn't there mysql module? When I execute `php -m`, there aren't something that refers to mysql. – ryochanuedasan Apr 03 '16 at 16:26
  • have you upgraded php from php5? – Federkun Apr 03 '16 at 16:39
  • Please note php-mysqlnd (which is for php-common already installed) is not the same than php70-php-mysqlnd (for parallel installation of multiple version). – Remi Collet Apr 03 '16 at 17:02
  • @Federico I'm sorry but I don't remember how to install php-7. – ryochanuedasan Apr 04 '16 at 14:29
  • or for Centos and php7.1 yum install php71-php-mysqlnd – vr_driver Feb 10 '18 at 15:19
7

Please remind that the mysql extension is deprecated and doesn't exists anymore with PHP 7.

The php-mysqlnd package provides only the mysqli and pdo_mysql extensions.

The php-pecl-mysql is also available, build from a git snapshot, provided for compatibility for legacy applications, but is not supported.

From the original question:

Installed: php-common-7.0.4-1.el6.remi.x86_64 (@remi-php70)

You have php 7.0.4 installed from remi-php70, but the repository is not enabled. You need to enabled it, so yum will find the right package matching the installed version.

From the Configuration Wizard instructions:

yum install yum-utils
yum-config-manager --enable remi-php70
yum install php-mysqlnd

Notice: the correct command to install an "foo" extension is yum install php-foo, so "yum install php-mysql" will install the package which provides the mysql extension (so php-pecl-mysql), "yum install php-mysqli" will install the packages which provides the mysqli extension (so php-mysqlnd).

Remi Collet
  • 6,198
  • 1
  • 20
  • 25
  • Thank you very much for your reply! I can install mysqli in that way and use it! It seems I need to study about "yum", "remi", "package"... or something like that. – ryochanuedasan Apr 04 '16 at 14:31