CentOS / RHEL: Install MySQL PHP Extension

How do I install a module or extension for PHP applications that use MySQL databases under CentOS / Redhat / RHEL / Fedora Linux?

You need to install php-mysql module using the yum command which contains a dynamic shared object that will add MySQL database support to PHP. MySQL is an object-relational database management system. PHP is an HTML-embeddable scripting language. If you need MySQL support for PHP applications, you will need to install this package and the php package:
# yum install php php-mysql httpd

Finally, restart apache web server:
# service httpd restart


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig 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 glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep 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
3 comments… add one
  • Jeff Lynn Feb 2, 2011 @ 18:56

    Hi,

    Can you help me to resolve php-mysql extension configuration problem?

    I had RHL enterprise 5 installed on my server and found that the PHP installed has
    no php-mysql support from phpinfo().

    I tried your suggested instruction of :

    yum install php php-mysql httpd

    and got the following response? What do I have to do to resolve this?

    [root@rhl-server ~]# yum install php php-mysql httpd
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    Nothing to do

    Thanks for any info

    Jeff

  • Dave Sep 27, 2011 @ 2:42

    My web hosting tech support could not solve this issue. So, thanks for posting the how to. You saved me many hours of work. Glad I finally found this in Google.

    Dave

  • Aneslin Nov 14, 2012 @ 14:49

    I hv installed this, and I got this message when I tried to install wordpress,

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

    How can I fix it ?
    thanks

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum