I host my own WP site on a Debian/Raspbian buster server.

I upgraded PHP 7.1 to 7.3 and the site broke.

I can't understand why it broke because mysql_connect() is deprecated for 7.x (though wp-db.php seems to use it extensively - while WP nags you to upgrade to 7.3). So I looked to enabling the various modules in the fresh 7.3 install php.ini. MySQLi was commented out, so I enabled that (and a few others) but still get the same error.

Call to undefined function mysql_connect()... wp-db.php on line 1643

which is...

    if ( WP_DEBUG ) {
  1643                  $this->dbh = mysql_connect( $this->dbhost, $this->dbuser, $this->dbpassword, $new_link, $client_flags );

Php info references MySQLi several times so I'm assuming it's running. The same for mysqlnd.

I know this question gets asked a lot. But I have tried just about everything out there.

How can I get my site working again on 7.3?

Edit: I tried disabling plugins by renaming the dir and got the same result. I suspect the issue is my 7.3 PHP config, since 7.0 worked fie.


I mean your php.ini is changed, check for the entry extension=php_mysqll.dll.

(If you has no knowledge where is your used php.ini - see https://stackoverflow.com/questions/8684609/dude-wheres-my-php-ini)

Is this entry active, has no ; before the string. After change of the php.ini you need a restart of mysql, like sudo /etc/init.d/mysql restart.

Also a note, check that mysql is installed for the newer php version, maybe via console or the phpinfo().

sudo apt-get install mysql-server mysql-common php7.3 php7.3-mysql

  • extension=php_mysqll.dll doesn't appear in my /etc/php/7.3/apache2/php.ini – square_eyes Sep 3 '19 at 11:20
  • Check also that mysql is installed and add the extension to the php.ini is not a task after install mysql. – bueltge Sep 3 '19 at 12:08
  • It is installed, yes – square_eyes Sep 3 '19 at 20:43

Your problem is either:

  • very old WordPress
  • custom modifications to WP Core

Update to a newer version of WordPress to resolve the problem

For example, if we look at the current WP source code, it doesn't use mysql_connect and hasn't for years:


            if ( WP_DEBUG ) {
                mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );
            } else {
                // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
                @mysqli_real_connect( $this->dbh, $host, $this->dbuser, $this->dbpassword, null, $port, $socket, $client_flags );

It won't be enough to just change mysql_connect to mysqli_real_connect though, as there are other changes. So update to the latest WordPress

  • Interesting observation. I regularly update from the UI, and updated before upgrading to PHP 7.3. – square_eyes Sep 3 '19 at 20:44
  • Since I feel like I have tried everything else (spent days on this) I'll do a manual install of core files. – square_eyes Sep 3 '19 at 20:45
  • I have zero idea what is going on. A clean install worked (vanilla site). I started copying across elements in the hope of picking up what broke it. Using the default clean theme and no plugins I connected it to the old DB. It worked! Then I copied across my old wp-config.php and it broke! I have rebuilt the site (added the plugins theme and child theme one by one) off the new install and it all works on 7.3. Could it have been the hashes somehow? – square_eyes Sep 4 '19 at 22:04
  • As a side, even when I was on 7.1, WP Chron wasn't working. This is now working too. I had recently migrated servers so it's likely that. Just most stuff was working and only broke when I upgraded PHP. – square_eyes Sep 4 '19 at 22:40
  • Hashes shouldn't make a difference, without knowing the contents of your wp-config.php it's impossible to comment, but sharing that file as is would be a security breach – Tom J Nowell Sep 4 '19 at 23:01

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.