none
Error establishing a database connection

    Question

  • Hi all,

     

    I'm setting up WordPress to my local PC. I'm able to setup PHP 5.3 without any error as well as database information like database name, new login information which is mapped to the newly created database. When I open WordPress in Chrome with this address: http://localhost/wp-sqlsrv/, it is opened successful with the default error say: something like missing wp-config.php which is normal because it is my first time to run wordpress. And I follow the instruction on next page where database information is asked, and database type is SQL Server using MS PHP driver, and hit Submit.

    But what I got is Error Establish a Database Connection, and now I'm stuck here, wonder what do I miss? can somebody give me a clue or idea? 

    Also, I tried to modified ws-config.php so it will have the database information:

    define('DB_NAME', 'wordpress');    // The name of the database

     

    define('DB_USER', 'wordpress');     // Your MySQL username

     

    define('DB_PASSWORD', '1234567890'); // ...and password

     

    define('DB_HOST', 'localhost');    // Change this to the IP address of your 

     

    database

     

    define('DB_CHARSET', 'utf8');

     

    define('DB_COLLATE', '');

    but this time it directly we to a blank page when tried to access to  http://localhost/wp-sqlsrv/ again.

     

    Thanks,

     

    Sam.

     

    Wednesday, July 27, 2011 10:00 PM

Answers

  • Sorry for the typo. This is the command that works for me: icacls . /grant "IIS_IUSRS":F /T

    The VC6 vs. VC9 issue depends on your PHP installation. If you have a PHP build for Windows, you probably have a VC9 build. I would enable both the prodedural and PDO drivers. So you need this in your php.ini file:

         extension=php_sqlsrv_53_nts_vc9.dll

         extension = php_pdo_sqlsrv_53_nts_vc9.dll

    That way, you will have the option of using either one when you install WordPress.

    Again, hope that helps.

    -Brian


    This posting is provided "AS IS" with no warranties, and confers no rights. http://blogs.msdn.com/brian_swan
    • Marked as answer by KJian_ Thursday, August 11, 2011 9:20 AM
    Thursday, July 28, 2011 10:23 PM

All replies

  • Hi Sam,

    Please first verify if the connection information is vaild.

    To install WordPress on SQL Server, I think you can refer to the following link:

    http://wordpress.visitmix.com/development/installing-wordpress-on-sql-server

     

    Jian Kang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Get or Request Code Sample from Microsoft
    If you have any feedback, please tell us.
    Thursday, July 28, 2011 7:30 AM
  • I've tried installing WordPress using the link Jian provided, but I think it's a bit out of date (I ran into troubles). I had much better luck doing this:

    1. Download WordPress from here: http://wordpress.org/
    2. Copy wordpress directory to inetpub/wwwroot.
    3. Create wordpress database using Management Studio.
    4. Download the SQLSRV plugin from here: http://wordpress.org/extend/plugins/wordpress-database-abstraction/installation/, and follow the instructions through step 3.
    5. Open a command prompt with Admin priviliges, change directory to the wordpress directory and run this command: icacls . /grant "IIS_USRS":F /T
    6. Finish the instructions on the plugin page and complte the WordPress installation.
    7. Remove Write permissions from the IIS_USRS user for the wordpress directory, but leave the permissions in place for the wp-content directory.

    Hope that helps.

    -Brian


    This posting is provided "AS IS" with no warranties, and confers no rights. http://blogs.msdn.com/brian_swan
    • Proposed as answer by Skylimey Tuesday, March 25, 2014 5:30 AM
    • Unproposed as answer by Skylimey Tuesday, March 25, 2014 5:32 AM
    Thursday, July 28, 2011 4:07 PM
  • Hi Brian,

    I ran to the "Error establishing a database connection" with the link Jian provided (actually before Jian replied me :D, not your fault, I also found it on Google).

    In step 5, I think the syntax is wrong as I got this error when I executed the command:

    C:\inetpub\wwwroot\wp-sqlsrv>icacls ./grant "IIS_USRS":F /T

    Invalid parameter "IIS_USRS":F

    And I replaced it with IIS_IUSRS, but still have the same error.

    I also tried icacls ./grant IIS_IUSRS:F /T, still no luck

    Regarding PHP, I noticed that there are several extensions but which one should I use? does PHP settings (php.ini) will effect the installation of WordPress?

    These 2 extensions below are enabled: 

    php_sqlsrv_53_nts_vc6.dll

    php_sqlsrv_53_nts_vc9.dll

    with this syntax:

    extension=php_sqlsrv_53_nts_vc6

    extension=php_sqlsrv_53_nts_vc9

     

    Thanks.

    Thursday, July 28, 2011 5:03 PM
  • Sorry for the typo. This is the command that works for me: icacls . /grant "IIS_IUSRS":F /T

    The VC6 vs. VC9 issue depends on your PHP installation. If you have a PHP build for Windows, you probably have a VC9 build. I would enable both the prodedural and PDO drivers. So you need this in your php.ini file:

         extension=php_sqlsrv_53_nts_vc9.dll

         extension = php_pdo_sqlsrv_53_nts_vc9.dll

    That way, you will have the option of using either one when you install WordPress.

    Again, hope that helps.

    -Brian


    This posting is provided "AS IS" with no warranties, and confers no rights. http://blogs.msdn.com/brian_swan
    • Marked as answer by KJian_ Thursday, August 11, 2011 9:20 AM
    Thursday, July 28, 2011 10:23 PM