≡ Menu

Your PHP installation appears to be missing the MySQL extension which is required by WordPress Error and Solution

I‘m setting up WordPress based blog system under Debian or Ubuntu Linux. I am getting an error which read as follows:

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

How do I fix this problem under Debian or Ubuntu Linux?

First, make sure MySQL server is running. Type the following command at a shell prompt:
# /etc/init.d/mysql status
If MySQL is not running, enter:
# /etc/init.d/mysql start
If MySQL is not installed, type the following command to install MySQL server:
# apt-get install mysql-server
Make sure MySQL module for php5 is installed:
# dpkg --list | grep php5-mysql
To install php5-mysql module enter:
# apt-get install php5-mysql
Next, restart the Apache2 web server:
# /etc/init.d/apache2 restart
Now PHP support for MySQL should work without a problem. Also make sure you set localhost or as MySQL hostname while performing wordpress installation.

Share this tutorial on:

Your support makes a big difference:
I have a small favor to ask. More people are reading the nixCraft. Many of you block advertising which is your right, and advertising revenues are not sufficient to cover my operating costs. So you can see why I need to ask for your help. The nixCraft, takes a lot of my time and hard work to produce. If you use nixCraft, who likes it, helps me with donations:
Become a Supporter →    Make a contribution via Paypal/Bitcoin →   

Don't Miss Any Linux and Unix Tips

Get nixCraft in your inbox. It's free:

{ 38 comments… add one }
  • Deb April 27, 2008, 8:32 pm

    I’m having the same problem trying to install on my localhost in Windows XP environment – any tips on how to fix that? I tried the above and that didn’t work. I’m running Apache 2 and PHP MyAdmin 5.2 (I believe). Everything else works fine and I can create and access MySQL databases in PHP MyAdmin without any issues.

  • Callum August 3, 2008, 11:09 am

    The reason it didn’t work is because this is for a linux environment, not Windows.

  • David October 14, 2008, 8:13 am

    Thanks, that did it for me.

  • billythekid December 13, 2008, 12:40 am

    Thanks for this, I’ve been trying various “fixes” all night, this did the trick for me. Props!

  • Matt December 30, 2008, 4:40 am

    This was super useful. Thanks for the post.

  • Mariana April 6, 2009, 11:43 am

    I am trying to install wordpress under debian.
    It is not my first installation, neither the second. It always gone ok.
    Not I got the same error pointed out here (you can go to the website). I do have php-server installed and running, I do have php5 installed. I do have the module php5-mysql.

    And it still gives me the same error.

    Who can help me?

    Thanks, Mariana

  • Mariana April 6, 2009, 11:45 am

    Sorry I wrote “Not I got the same error ..”, I meant “Now I got the same error..”

    And also “I do have php-server installed and running”, I meant “I do have mysql-server installed and running”

  • Biju Subhash April 29, 2009, 11:25 am

    Thank you for sharing…
    nice post..

    Biju Subhash

  • Nguyen Lan May 7, 2009, 7:46 pm

    Thanks for shared but I host on godaddy so How can I do with this problem. My host is shared hosting on Window. Can you show me.

  • John May 12, 2009, 1:58 am

    Thanks so much!

    Followed your process, step by step. Worked like a charm first time!

  • aldeol July 13, 2009, 10:09 am

    Thank you so much. I have solved my problem. Thank you again for this useful article…

  • BentleyCoup August 15, 2009, 7:25 am

    Thanks i stumbled on the same problem. One would think that the mysql module would be included with PHP5 without asking for it.

  • Jasper December 16, 2009, 2:11 pm

    Thanks. This was a life saver for my local installation on a Ubuntu Virtual Partition!

  • lacops June 10, 2010, 10:38 am

    So simple and yet such a great help!

    Thank you so much :-)

  • blesbok June 11, 2010, 11:12 pm

    Thank you, this was very handy. Turned out all that was left to do was to restart Apache. Almost felt I could kick myself…

  • Phoreys July 21, 2010, 4:01 pm

    Nice! That fixed my issues…

  • John Connor September 27, 2010, 7:24 pm

    Thanks, that solved my problem.

  • asu February 13, 2011, 1:25 am

    stupid solution…:(

  • PB April 11, 2011, 2:04 am

    This fixed it for me. Gracias!

  • Ghostetr January 4, 2012, 12:55 am

    hehe i just reinstalled my ubunto and updated to version 11.10
    i had install the mysql extension but forgot to start it
    ty for your help :D

  • Cindy November 17, 2012, 12:33 pm

    Morning….The blog has been working for YEARS, then all of a sudden this morning I am getting: Your PHP installation appears to be missing the MySQL extension which is required by WordPress.. I’ve read the above but I don’t know what it means. I also can’t access my control panel inside of wordpress anymore. Can someone please give me step-by-step on how to fix this? I need this back up asap. Thank you!

    • ITN John November 17, 2012, 1:12 pm

      First, these commands need to be typed using a ssh session. Can you access your server using SSH? Are you a server admin? Is your server is managed by a hosting company? Is it on a shared hosting account? If so contact tech support. These commands will only work if you know how to use ssh and login as root user.

  • Tom January 15, 2013, 8:35 pm

    Old post I know, but I’m trying to run MySQL 5.1.58 on Ubuntu 12.04, It’s a task I was assigned. I’m also trying to run Apache and PHP5. I compiled MySQL 5.1.58 and apt-get both Apache and PHP5. Everything works great, but when I try to connect PHP and MySQL with php5-mysql, it breaks MySQL.

    When I run ./bin/mysqld_safe –user=mysql &, I get an error about /var/lib/mysql for .err, not being there. I tried ln -s to the mysql install location, that fixes that error. When I check the .err file it says:

    [ERROR] Can’t find messagefile ‘usr/share/english/errmsg.sys’
    [Note] Plugin ‘FEDERATED’ is disabled.
    /usr/local/mysql/bin/mysqld: Uknown error 1146
    [ERROR] Can’t open the mysql.plugin table. Please run mysql_upgrade to create it.
    InnoDB: Initializing buffer pool, size = 8.0M
    InnoDB: Completed initialization of buffer pool
    InnoDB: Operating system error number 13 in file operation.
    InnoDB: The error means mysqld does not have the access rights to
    InnoDB: the directory.
    InnoDB: File name ./ibdata1
    InnoDB: File operation call: ‘create’.
    InnoDB: Cannot continue operation.
    mysqld_safe mysqld from pid fiel /var/run/mysqld/mysqld.pid ended

    I don’t understand what ‘access rights’ mysqld needs, when I check them, mysql user has ownership of data file in /usr/local/mysql/. Is there something I’m missing/doing wrong? Appreciate any help.

  • Shahreer March 18, 2013, 6:00 pm

    Hi, I need this solution on Windows not Linux. Pls help me!!!

  • Shahul August 9, 2013, 9:21 am

    Thanks :) It worked

  • Ernesto David Lazalde December 26, 2013, 11:03 pm

    As an alternative to the above solution, you can simply apply the following patch to your Wordpress:


    The full instructions are at the link, but it simply involves extracting the compressed folder and copying the db.php file into your wp-content directory. It quickly fixed the problem for me (I am using Fedora Linux with PHP 5.5.7).

  • Marco April 1, 2014, 5:04 pm


  • Suliman April 3, 2014, 7:02 pm

    It works just fine with me, Thanks alot

  • jimmy July 1, 2014, 5:51 am

    Thanks!! It worked.

  • emmanuelbarturen February 22, 2015, 11:07 pm

    the best answer, thanks you!!

  • Doug July 10, 2015, 6:39 pm

    Thank you for your brief explanation! Totally helped me!

  • den pha August 22, 2015, 1:15 am

    It’s amazing in support off me tо ave a web pagе,
    which іs valuable foг my knowledge. thankѕ admin

  • Petar October 21, 2015, 12:24 pm

    Thank you for your help!!!

  • Philip November 9, 2015, 12:38 pm

    THANKS!!!!!!! :)

  • ajay sharma January 31, 2016, 9:19 am

    Thanks a lot buddy. This solved my problem :)
    Great blog.

  • Eddy March 20, 2016, 5:09 am

    Thanks. This work for me as well.

  • vivek May 27, 2016, 10:10 am

    Thanks, It worked

  • Tom November 28, 2016, 7:03 pm

    After I upgraded from php 5.5.9 to 5.5.38 under Ubuntu 14.04.5, and disabled the old (a2dismod php5) and enabled the new (a2enmod php5.5), I get the error (thread title). My mysqld is still running though… So I recovered the site by reversing the a2dis/enmod calls.

    When I run the “dpkg –list | grep php5-mysql”, I get nothing, so for 5.5.38, I need to apt-get this package? I didn’t need this for 5.5.9 then? If I get it, can I revert back to 5.5.9 if I wanted to?


Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , ,