5

I get the following error: Fatal error: Class 'mysqli' not found in my php script I have php5.3.3-7 installed and I get this when I run apt-cache show php5-mysql

Description: MySQL module for php5
 This package provides modules for MySQL database connections directly from
 PHP scripts.  It includes the generic "mysql" module which can be used
 to connect to all versions of MySQL, an improved "mysqli" module for
 MySQL version 4.1 or later, and the pdo_mysql module for use with
 the PHP Data Object extension.

There is nothing about mysql at all in php info. How do I find the extention and do I have to istall it? There are many references to mysqli in my php.ini. But something is wrong.

mike628
  • 45,873
  • 18
  • 40
  • 57
  • 2
    possible duplicate of [Fatal error: Class 'MySQLi' not found](http://stackoverflow.com/questions/666811/fatal-error-class-mysqli-not-found) – genesis Jul 17 '11 at 12:25
  • 1
    Not a duplicate; the OP doesn't have to install MySQLi by hand. – womble Jul 17 '11 at 13:03

3 Answers3

16

Have you actually installed the php5-mysql package? apt-cache show will give you information on packages that aren't installed (you want dpkg -l to list installed packages). If the package is installed, double-check that it's enabled (/etc/php5/conf.d/mysql.ini is the place to look).

womble
  • 12,033
  • 5
  • 52
  • 66
  • This one made me feel stupid, but mysql was totally not even installed on my box. Thanks! – michaelday Oct 05 '13 at 02:50
  • I actually came here looking for which package to install: `php5-mysql` or `php5-mysqlnd`. The latter uses the "native driver," whatever that is. Which one should I use? I'm using Debian stretch, is the native driver supplied closed source by Oracle or something? – Luc Aug 27 '15 at 14:27
  • @Luc you'd be better off asking a new question for that. – womble Aug 27 '15 at 20:34
  • If it's not enabled, how would you go about enabling? – Philll_t Apr 27 '16 at 18:30
  • Questions should go in questions, not comments on five year old answers. – womble Apr 27 '16 at 23:04
  • If you're on 16.04 you'll want to use: `apt-get install php7.0-mysql` – deweydb Sep 16 '16 at 22:50
2

Sounds like you just need to install MySQLi.

If you think you've done that and still have a problem, please post your operating system and anything else that might help

Brad Mace
  • 27,194
  • 17
  • 102
  • 148
genesis
  • 50,477
  • 20
  • 96
  • 125
1

I had to reinstall it to get rid of this error:

apt-get remove php5.6-mysql
apt-get install php5.6-mysql
l0pan
  • 476
  • 7
  • 11