Trying to run a search and replace but am getting an error

 Call to undefined function mysql_connect() in E:\xampp\htdocs\test\wp-includes\wp-db.php:1688

I have checked my WP files and have both mysqli_connect and msql_connect referenced in there. I have tried to replace all mysql_connect references to mysqli_connect however I then get the same error for the new name

 Call to undefined function mysqli_connect() in E:\xampp\htdocs\test\wp-includes\wp-db.php:1688

When I run wp --info I get:

OS:     Windows NT 10.0 build 18363 (Windows 10) AMD64
Shell:  C:\Windows\system32\cmd.exe
PHP binary:     C:\PHP7\php.exe
PHP version:    7.4.9
php.ini used:   C:\PHP7\php.ini
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       E:\xampp\htdocs\test
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.4.0

  • Are you installing WordPress for the first time? Does your server meet the hosting requirements? Also, never edit WordPress core files. mysql_connect is referenced for backwards compatibility reasons. Your system would use the right mysql function if you had the correct modules installed. Feb 27, 2021 at 11:35
  • This is on my local machine, I just installed xampp and haven't used it before. The site I'm moving to xampp is a local localbyflywheel site, I have moved the SQL database to MySQL server and make a folder in the htdocs 'test' and copied and pasted the wp files from local by flywheel to the xampp/test folder
    – iheartex
    Feb 27, 2021 at 11:50
  • Though the site seems to work? I can navigate to it on my local but it straight away redirects me to the old site which is why I am trying to use wp cli to search and replace
    – iheartex
    Feb 27, 2021 at 11:52
  • You need MySQL/MariaDB running and you need the MySQLi PHP extension installed. C:\PHP7\php.exe is not where XAMPP keeps its PHP though, it looks like your have conflicting PHP installs. This isn't a WordPress problem, this is a local server setup problem
    – Tom J Nowell
    Feb 27, 2021 at 14:43
  • Where should i go from here then? Ive watched a few tutorials and they have never installed mySQLi extension?
    – iheartex
    Feb 27, 2021 at 16:14


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.