Database login problems with IIS7

Discussion in 'Windows / IIS' started by wmc531, Jan 14, 2014.

  1. I just recently upgraded from IIS6 to IIS7 and migrated the site, but now I'm having trouble accessing my database pages.
    Furthermore, my customers can't login to their accounts at all...
    What has changed with IIS7 and what code do I need to use to login and gain access to my database?
    Thanks for any input!

    With IIS6 I used a db.php file inside the database folder with the following code:
    <?php
    @ $db = mysql_connect("my sql connection address", "myuser or login name", "my password");
    mysql_select_db('MYSQLDB_name & assigned numbers') or die('Unable to connect to database');
    if (!$db)
    {
    echo "Error, could not connect to the database.";
    exit;
    }
    ?>

    I also used the following code in a config.php file in the program:
    <?php
    $_DB_HOST_NAME = 'my sql connection address';
    $_DB_NAME = ''MYSQLDB_name & assigned numbers'';
    $_DB_USER_NAME = 'myuser or login name';
    $_DB_PASSWORD = 'my password';
    ?>

    And a dbquery.php file in the program:
    <?php
    require_once('config.php');
    function dbQuery ($sql) {
    global $_DB_HOST_NAME, $_DB_NAME, $_DB_LOGIN, $_DB_PASSWORD;
    mysql_connect($_MYSQL_SERVER_NAME, $_DB_LOGIN, $_DB_PASSWORD) or die("Could not connect: " . mysql_error());
    mysql_select_db($_DB_NAME) or die ("Can't use $_DB_NAME : " . mysql_error());
    $result = mysql_query($sql) or die("Invalid query: $sql<br>" . mysql_error());
    return $result;
    }
    ?>

    Do I need to change file names? Use different files? Change the code?
    Please help with specifics!
    Thanks!
     
  2. I don't think you should have to change your code since you are using PHP to connect to your MySQL database, can you provide us with a URL in your site that we can look at and see the failed connection?
     
  3. http://www.eigocafe.net/scheduler/maint_login.html

    Try this for testing:
    UserID: lc
    PW: lc14

    As you see, this is the error message I get:
    Could not connect: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file
     
    Last edited: Jan 14, 2014
  4. Oops! I made two mistakes in my original post regarding the dbquery.php file. My original code was not $_MYSQL_SERVER_NAME, it was $_DB_HOST_NAME,
    and not $_DB_LOGIN, it was $_DB_USERNAME...

    The correct original code for dbquery.php file is below:

    <?php
    require_once('config.php');
    function dbQuery ($sql) {
    global $_DB_HOST_NAME, $_DB_NAME, $_DB_USERNAME, $_DB_PASSWORD;
    mysql_connect($_DB_HOST_NAME, $_DB_USERNAME, $_DB_PASSWORD) or die("Could not connect: " . mysql_error());
    mysql_select_db($_DB_NAME) or die ("Can't use $_DB_NAME : " . mysql_error());
    $result = mysql_query($sql) or die("Invalid query: $sql<br>" . mysql_error());
    return $result;
    }
    ?>

    After migration, two items on the DASP.net control panel changed names...Host Name changed to MySQL Sever Name
    and Username had changed to Login

    I tried coding the dbquery file both ways with failed results each time.
    Don't know if that would make a difference, but sorry for the mistake anyway.
     
  5. Thanks for the suggestion, that nither works nor anyother modifications or combinations that I try.

    As I said, I using the following files to authenticate, connect and login to my database:
    config.php (has only the login info that is supposed to be secure)
    dbQuery.php (has leads or directions for the database to follow to connect)

    The following file is in the database folder at the top of my website directory:
    db.php (also has the same info as config.php with additional code that is supposed to be secure)

    Which file(s) do the following codes belong in?

    SET SESSION old_passwords=FALSE;
    SET PASSWORD = PASSWORD('[your password]');

    define('CLIENT_LONG_PASSWORD',1);
    mysql_connect('[your server]','[your username]','[your password]',false, CLIENT_LONG_PASSWORD);

    Thanks...
     
  6. SET SESSION old_passwords=FALSE;
    SET PASSWORD = PASSWORD('[your password]');

    Needs to be ran in your MySQL database, try doing that first.

    Have you considered upgrading to the newer version MySQL?

    That would solve the password incompatibility error immediately.
     
  7. >Needs to be ran in your MySQL database, try doing that first.
    Do you meant from the back side or within the DB?
    Have no idea how to do that...please send step by step instructions of what you mean and how to do that.

    >Have you considered upgrading to the newer version MySQL?
    Do you mean to 2012IIS8?
    I just upgraded from 2003IIS6 to 2008IIS7 and migrated on Jan 4th.
    S..t, that made everthing even worse!!!
    Since then, can't even access my DB program at all...and my web pages can't be seen on the Internet using php...headers & footers are missing, too!! Had to change many of the pages to htm/html just to be able to see the page bodies. It looks like crap!
    This whole situation has been a major cluster f..k from H..l.
     
  8. I meant that you would have to log in to your MySQL database directly and execute this statement, replacing [your password] with your database user’s actual password.

    In order to connect to your MySQL database you will have to use a management client that is still able to use your database’s older password format.

    I have tested the following and it is able to connect.

    http://sourceforge.net/projects/mysqlcc/files/?source=navbar

    Download the Win32 version if you are using Windows. The other versions are for Linux.

    Download and install MySQL Control Center, then use it to connect to your database.

    If you require assistance in connecting, open up a ticket with the Support Department but keep in mind that they can only assist you with the connection, not actually executing this statement or getting your PHP code to work.

    Once connected, left click on your database and select the “SQL” button to start a new query.

    Enter the following, replacing [Your Password] with your actual database password.

    SET SESSION old_passwords=FALSE;
    SET PASSWORD = PASSWORD('[your password]');

    And then try to use your PHP code to connect to your database.

    No, I mean you should upgrade your MySQL database to use MySQL 5 instead of the older MySQL 4 that it is currently using.

    Check your Control Panel’s MySQL Manager and see how much disk space your current database is using, if you have free space I suggest that you try removing some from your current MySQL database and then using it to provision a new MySQL database on a MySQL 5 server, you can then dump your old database content into this new MySQL 5 database and your PHP code should be able to connect to it.

    This Knowledge Base article shows you how to use the mysqldump utility to obtain a backup of your current database; you can then use the same utility to upload your backup to the new MySQL Server however you will need to have the older version of MySQL (before MySQL 5) installed on your local machine in order for the utility to connect to your older MySQL database.

    https://support.discountasp.net/KB/a240/how-to-migrate-your-current-mysql-databasetables-to.aspx
     
    martino and mjp like this.

Share This Page