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:

ADVERTISEMENTS

Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements None
Time N/A

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 127.0.0.1 as MySQL hostname while performing wordpress installation.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
38 comments… add one
  • Deb Apr 27, 2008 @ 20:32

    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 Aug 3, 2008 @ 11:09

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

  • David Oct 14, 2008 @ 8:13

    Thanks, that did it for me.

  • billythekid Dec 13, 2008 @ 0:40

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

  • Matt Dec 30, 2008 @ 4:40

    This was super useful. Thanks for the post.

  • Mariana Apr 6, 2009 @ 11:43

    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 Apr 6, 2009 @ 11:45

    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 Apr 29, 2009 @ 11:25

    Thank you for sharing…
    nice post..

    Biju Subhash

  • Nguyen Lan May 7, 2009 @ 19:46

    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.
    Thanks

  • John May 12, 2009 @ 1:58

    Thanks so much!

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

  • aldeol Jul 13, 2009 @ 10:09

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

  • BentleyCoup Aug 15, 2009 @ 7:25

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

  • Jasper Dec 16, 2009 @ 14:11

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

  • lacops Jun 10, 2010 @ 10:38

    So simple and yet such a great help!

    Thank you so much :-)

  • blesbok Jun 11, 2010 @ 23:12

    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 Jul 21, 2010 @ 16:01

    Nice! That fixed my issues…

  • John Connor Sep 27, 2010 @ 19:24

    Thanks, that solved my problem.

  • asu Feb 13, 2011 @ 1:25

    stupid solution…:(

  • PB Apr 11, 2011 @ 2:04

    This fixed it for me. Gracias!

  • Ghostetr Jan 4, 2012 @ 0:55

    THANKS THIS WAS A HUGE HELP :D
    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 Nov 17, 2012 @ 12:33

    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 Nov 17, 2012 @ 13:12

      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 Jan 15, 2013 @ 20:35

    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 Mar 18, 2013 @ 18:00

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

  • Shahul Aug 9, 2013 @ 9:21

    Thanks :) It worked

  • Ernesto David Lazalde Dec 26, 2013 @ 23:03

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

    http://wordpress.org/plugins/mysqli/

    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 Apr 1, 2014 @ 17:04

    Thanks!!

  • Suliman Apr 3, 2014 @ 19:02

    It works just fine with me, Thanks alot

  • jimmy Jul 1, 2014 @ 5:51

    Thanks!! It worked.

  • emmanuelbarturen Feb 22, 2015 @ 23:07

    the best answer, thanks you!!

  • Doug Jul 10, 2015 @ 18:39

    Thank you for your brief explanation! Totally helped me!

  • den pha Aug 22, 2015 @ 1:15

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

  • Petar Oct 21, 2015 @ 12:24

    Thank you for your help!!!

  • Philip Nov 9, 2015 @ 12:38

    THANKS!!!!!!! :)

  • ajay sharma Jan 31, 2016 @ 9:19

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

  • Eddy Mar 20, 2016 @ 5:09

    Thanks. This work for me as well.

  • vivek May 27, 2016 @ 10:10

    Thanks, It worked

  • Tom Nov 28, 2016 @ 19:03

    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?

    Thanks.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.