Install Wordpress and hits the following error message :


Fatal error: Uncaught Error: Call to undefined function mysql_connect() 
	in C:\nginx-1.12.1\www\wordpress\wp-includes\wp-db.php...

Tested

  1. PHP 7.1.10
  2. Wordpress 4.8.3
  3. Nginx 1.12.1
  4. MySQL 5.7.17
  5. Windows 10

Solution

To install Wordpress, PHP needs Mysql extension, to fix this, loads php_mysqli.dll in php.ini file.

php.ini


; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"

extension_dir = "ext"

;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll
;extension=php_exif.dll      ; Must be after mbstring as it depends on it

extension=php_mysqli.dll

;extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client
;extension=php_openssl.dll

On Windows, default PHP dll extensions, including php_mysqli.dll are stored in the c:\\your-php-path\\ext folder, make sure the extension_dir path is pointing to the correct folder.

Restart PHP, done.

References

  1. PHP php_mysqli.dll
  2. PHP extension_dir