Categories
Linux

Ubuntu: use PHP5-MySQL extension to use MySQL in PHP scripts

Say you have installed PHP MySQL Apache etc in Ubuntu but you didnot install proper extensions , e.g php5-mysql extensions then you can get this type of errors-

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

The above error is found in WordPress when you have Apache running, mysql running, php running but dont have proper PHP5-MySQL extension.

So how to check PHP5-MYSQL extension / module status in your Ubuntu ? Is it installed or not ?

Make sure MySQL module for php5 is installed by using this command, whether it is installed or not ?

dpkg –list | grep php5-mysql

In this Ubuntu PC , php-mysql module is installed , so when I am using the command it shows the following output

diet@ubuntu-HP-Pavilion-dv4-Notebook-PC:~$ dpkg –list | grep php5-mysql
ii php5-mysql 5.3.10-1ubuntu3.10 MySQL module for php5

1. To install PHP5-MYSQL module in Ubuntu:

$ apt-get install php5-mysql
or
$  sudo apt-get install php5-mysql

2. Next check Apache Server is running or not ? Use this command

/etc/init.d/apache2  status

diet@ubuntu-HP-Pavilion-dv4-Notebook-PC:~$ /etc/init.d/apache2 status
Apache2 is running (pid 1020).

3. If Apache server is running then restart Apache server

$  /etc/init.d/apache2  restart
or
you may need to use with sudo as follows-

$ sudo  /etc/init.d/apache2  restart