• Hi,

    I’m trying to setup WordPress on a self-hosted server that must be internal.

    Windows Server 2008 R2
    IIS 7.5
    PHP 7.2.7
    MySQL 8.0.11
    MS VC++ 2015 x64 14.0.23026

    After going through a couple different guides online, I have IIS running with handler mappings including php using the fastcigmodule.

    When going to the internal site: http://wp-projects/wp-admin/install.php, I receive an error: Error establishing a database connection. I have checked that the db exists through:

    show databases;

    I am able to login as both root and the newly created “wpuser” through MySQL 8.0 Command Line Client and from the terminal by navigating to mysql’s path and using:

    mysql -uroot -p

    Running netstat -an shows that all interfaces are listening on 3306

    So the db exists, the mysql user(s) are able to login directly and mysql listens as expected.

    A potentially related problem is that http://wp-projects/phpinfo.php runs correctly. However, http://wp-projects/testconn.php does NOT work resulting in HTTP 500 Internal Server Error. The code is:

    $test Connection = mysql_connect(‘localhost’, ‘root’, ‘password’);
    if (!$testConnection) {
    die(‘Error: ‘ . mysql_error());
    echo ‘Database connection working!’;

    • This topic was modified 5 years, 12 months ago by jdoe87165.
    • This topic was modified 5 years, 12 months ago by jdoe87165. Reason: minor edits

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz


    mysql_connect() is deprecated in favor of mysqli_connect(). This explains why testconn.php does not work, but not why install.php has trouble, since it uses mysqli functions. This is related to appropriate PHP functions and unrelated to which SQL version you have running on your server.

    All I can suggest is be sure you have the correct DB connection values defined in wp-config.php .

    Thread Starter jdoe87165


    Changing mysql_connect to mysqli_connect in testconn.php still results in http 500.

    I’ve been over wp-config.php many times and the only thing that stands out is that I have no defined Authentication Unique Keys and Salts yet.

    // ** MySQL settings – You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define(‘DB_NAME’, ‘wpdb’);

    /** MySQL database username */
    define(‘DB_USER’, ‘wpuser’);

    /** MySQL database password */
    define(‘DB_PASSWORD’, ‘password’);

    /** MySQL hostname */
    define(‘DB_HOST’, ‘localhost’);

    /** Database Charset to use in creating database tables. */
    define(‘DB_CHARSET’, ‘utf8’);

    /** The Database Collate type. Don’t change this if in doubt. */
    define(‘DB_COLLATE’, ”);

    This is the newest WordPress archive and not part of a stack or bundle.

    Moderator bcworkz


    As long as the salt constants are defined as something, even if just ‘put your unique phrase here’, there would not be any issues due to this. But you may as well place unique phrases anyway. Using the link provided in the comment to get unique phrases is a super simple, secure way to do this. It takes mere seconds to complete when using the link.

    It’s apparent that PHP is not communicating with mySQL for some reason. Perhaps try for DB_HOST instead of localhost? I know they should both resolve to the same thing, but it’s made a difference for me in the past in similar but not identical situations. You can also try localhost:3306 or Again, there shouldn’t be any difference, but it’s worth a try.

    Thread Starter jdoe87165


    Unfortunately, none of these have worked:


    • This reply was modified 5 years, 12 months ago by jdoe87165.

    This error in my case had nothing to do with mysqli. It was the fact of using MySQL8, in which default password encryption option has been changed. It is clearly written in MySQL8 release notes and everyone has been warned of that before. I’ve written on how to fix this issue on my blog here: How to fix WordPress database connection for MySQL 8 it’s rather simple really, all you need to do is in my.cnf specify the correct default password encryption plugin to use.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Error establishing a db connection and http 500’ is closed to new replies.