Support » Fixing WordPress » Deprecated: mysql_connect() extension is deprecated use mysqli or PDO wp-db.php

  • Hi support team, I am having the issue not beeing able to access to admin area any more. Got this message in browser shown.

    Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in …/wp-includes/wp-db.php on line 1518

    Please advice, how to solve that.

    THANKS, Alex

Viewing 14 replies - 1 through 14 (of 14 total)
  • just reset your db user password.

    probably because of php upgrade, mysqli won’t work and the wpdb fallback tries to use the old mysql functions that causes the deprecated notice. and

    Apparently PHP 5.5/5.6 uses a different passwordhash (or something like that). So I had to set a new password in phpMyAdmin and enter it into the config.php.

    http://stackoverflow.com/a/35890185/4864081

    I had the same problem.

    FGD

    (@creativetopia)

    I tried resetting the password as mentioned by geminorum but it did not resolve my issue.

    I can login to the dashboard of my WordPress multisite but the front-end of the websites are white. When debugging, I received the same error. Plus a notice: register_uninstall_hook was called incorrectly. Only static class method or function can be used in an uninstall hook

    Any other ideas?

    FGD

    (@creativetopia)

    Ended up deactivating all my plugins and re-activating them. And boom, everything is backup.

    Hi Geminorum,

    I tried by using an other created db user with password and still running into the same problems (changed the domain url into MYSITE and FOLDER).

    Notice: Use of undefined constant DB_NAME - assumed 'DB_NAME' in /home/MYSITE/public_html/FOLDER/blog_de/wp-includes/load.php on line 368
    
    Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/MYSITE/public_html/FOLDER/blog_de/wp-includes/wp-db.php on line 1518

    Even when I de-activate all existing plugins!
    Any other suggestion would be helpful to solve this issue.

    THANKS, Alex

    Hey Alex,

    check your wp-config.php for define( 'DB_NAME', 'name_of_you_db' );

    for reference: Editing wp-config.php: Set Database Name

    probably something there. 🙂

    Hi again,

    I have checked and still get the problem. (FOLDER-RENAMED) Using the existing credentials with phpmyadmin will access to database. Same credential are in wp.config.php. I also cleared browser cookies, but still get the same result.

    Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/MYDOMAIN/public_html/MYSUBFOLDER/OTHERSUBFOLDER/wp-includes/wp-db.php on line 1518

    Do I need to use or change some PHP pages or am I in need to use a new WP installation and then use the existing DB?

    Any other ideas?

    Regards, Alex

    If I drop all plugins in “_plugins_off” folder and open browser again, I get this info:

    Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/MYDOMAIN/public_html/FOLDER/SUBFOLDER/wp-includes/wp-db.php on line 1518

    Notice: Die verwendete Konstruktoren-Methode für WP_Widget ist seit Version 4.3.0 veraltet! Verwende stattdessen
    __construct()
    . in /home/MYDOMAIN/public_html/FOLDER/SUBFOLDER/wp-includes/functions.php on line 3624

    Notice: Die verwendete Konstruktoren-Methode für WP_Widget ist seit Version 4.3.0 veraltet! Verwende stattdessen
    __construct()
    . in /home/MYDOMAIN/public_html/FOLDER/SUBFOLDER/wp-includes/functions.php on line 3624

    Notice: Die verwendete Konstruktoren-Methode für WP_Widget ist seit Version 4.3.0 veraltet! Verwende stattdessen
    __construct()
    . in /home/MYDOMAIN/public_html/FOLDER/SUBFOLDER/wp-includes/functions.php on line 3624

    Warning: Cannot modify header information – headers already sent by (output started at /home/MYDOMAIN/public_html/FOLDER/SUBFOLDER/wp-includes/wp-db.php:1518) in /home/MYDOMAIN/public_html/FOLDER/SUBFOLDER/wp-includes/pluggable.php on line 1228

    I tried by using an other created db user with password and still running into the same problems (changed the domain url into MYSITE and FOLDER).

    you have to generate new password for db user. old passwords won’t work because of different hashing in MySQL.

    I too have the problem. I have generated a new user, new password, given new user appropriate priviledges for the database. No change.
    Error is still:
    Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xxx/public_html/wp-includes/wp-db.php on line 1520

    Did you update wp-config.php to use that new user’s credentials though?

    Since this appears as one of top results when searching yahoo for this issue – thought I’d add what I did to stop in my case..

    On top of creating a new DB user and adding the new credentials to this wp-config as mentioned above –

    I went into phpmyadmin – my wp database – the wp users table.. selected the admin user I was logging in with – and change the password field, then selected md5 in the box next to it – and clicked save. At the same time I went into my wp-config and turned off debugging and debug logging – issue was then resolved.

    in between that and the other things mentioned in this thread, I had gone in and renamed the plugins folder, and then deleted almost all wordpress files and re-installed basically (after having a complete backup of all files and the database with add drop table selected) just in case.

    was re-doing the admin user password md5 the fix? or maybe just debug = false is suppressing me seeing the errors and causing troubles? or maybe it was the debug logging using a deprecated thing – I don’t know at this time.

    I had upgraded cpanel and apache recently – so maybe since this was created with older version of apache / cpanel / php – around wp 4.4.. then some updates and later problems – not sure.

    details on changing user pass through phpmyadmion and md5 and all that are in the codex (last I checked some years ago I think)

    Also, note this from the WP Codex: For Version 4.6, the database version (db_version in wp_options) changed to 37965, and the Trac revision was 38270.

    That is, if you’ve updated a site from 4.6 to 4.7 and the db_version remained the old one (37965), then you have to (1) you need to confirm that the WordPress version ID is the same in the version.php file as in the db_version of the wp_options table of the database, and if necessary (2) change the db_version to 38590 (as of 4.7) manually in the wp_options table [using PHPmyAdmin].

    Hope this works for you as it did for me!

    Hi all just came across this last night on a site I run. Basically I have turned off debug in the wp-config file which I know does not fix it but as a short term get you out of trouble is ok. now I have to find out what the hell is going on with the site to see if it can be fixed. If I find out I will put it up here

    In my case, I have the problem only when debug mode is on, but not when it’s off. So a simple trick is to add @ (suppress warning) at the function mysql_connect in wp-db.php, as it does when debug is off.

    It’s dirty, but it works for me. Just remember to check that when there is a problem next time.

    • This reply was modified 2 years, 9 months ago by robberviet.
    • This reply was modified 2 years, 9 months ago by robberviet.
Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Deprecated: mysql_connect() extension is deprecated use mysqli or PDO wp-db.php’ is closed to new replies.