Support » Installing WordPress » Error establishing a db connection and http 500

  • 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:

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

    • This topic was modified 3 months, 1 week ago by  jdoe87165.
    • This topic was modified 3 months, 1 week ago by  jdoe87165. Reason: minor edits

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

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

    (@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 .

    jdoe87165

    (@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

    (@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 127.0.0.1 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 127.0.0.1:3306. Again, there shouldn’t be any difference, but it’s worth a try.

    jdoe87165

    (@jdoe87165)

    Unfortunately, none of these have worked:

    localhost
    127.0.0.1
    localhost:3306
    127.0.0.1:3306
    10.0.50.10
    10.0.50.10:3306

    • This reply was modified 3 months ago by  jdoe87165.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.