Windows 7 PHP MySQL Connection Issues [duplicate]
Asked Answered
E

4

4

When I run $conn = mysql_connect($host, $user, $pass); I am able to get a connection to the database but when i do a var_dump($conn) I get back bool(true) which is limiting me from having multiple connection to multiple servers.

The original setup on this computer was XAMPP with a version of PHP 5.2 that was upgraded to PHP 5.3.4 via the PHP installer. It could connect to its local database with no problem (other than returning a boolean instead of the resource link identifier) but could not connect to any remote machines (and the ability to connect to remote machines has been confirmed). Without being able to come up with a solution, i upgraded to a version of XAMPP that has PHP 5.3.1 built in. I get exactly the same error after a fresh reinstall of XAMPP which is leading me to believe that this is a larger issue.

Edit 1 **

Moving to a clean install of windows and installing XAMPP and trying to run a mysql_connect to a remote server (PHP 5.3.1) i get the same error:

Warning: mysql_connect() [function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:554) in [Removed] on line 2

Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected in [Removed]p on line 2

Warning: mysql_connect() [function.mysql-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 in [Removed] on line 2
Easing answered 26/1, 2011 at 16:28 Comment(1)
I was with the same problem. This question / answer solve it: https://mcmap.net/q/279274/-cannot-connect-to-mysql-4-1-using-old-authenticationDivorcement
W
4

Check old_passwords option in your my.cnf file.

http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_old-passwords

If for whatever reason you can't switch to new passwords, you can't use mysqlnd as your MySQL driver, and need to switch back to the older one.

Some more information about mysqlnd

http://dev.mysql.com/downloads/connector/php-mysqlnd/

Wheeze answered 26/1, 2011 at 16:35 Comment(2)
I have tried the old_passwords suggestion (and just retried for the sake a due diligence) to no avail, I am currently loading mysqlnd with no change in behavior in both 5.3.1 and 5.3.4Easing
This can be fixed by downgrading your version of XAMPP from 1.7.4 to 1.7.3. Apparently the version that is currently published is a beta version even though it is not currently marked as such.Easing
B
4

Regarding the error posted in your edit, I had been getting the same error on Windows 7 using PHP 5.3.5 when connecting to MySQL 5.0.45 on Linux. The solution for me was to disable "old_passwords" in my.cnf AND run

set password = password('my password');

The error message doesn't make it clear that you have to do both steps in order to fix the problem. Hope this helps.

Barfly answered 11/3, 2011 at 19:21 Comment(0)
B
2

when you want to change your password and the server keeps on generating 16 bytes hashes, you may try as following:

1) generate 41bytes hash by yourself (using some hash generator website) for example password: 'qwerty' hash: 'aa1420f182e88b9e5f874f6fbe7459291e8f4601'

2) change the password SET PASSWORD FOR 'username' = '*aa1420f182e88b9e5f874f6fbe7459291e8f4601'

now you should be able to connect to the database using the new authentication method

Bickart answered 23/4, 2011 at 11:45 Comment(1)
Tried most other suggestions. This was the only answer that helped me. ThanksLinoel
G
0

I tried just about everything listed here (and elsewhere) to no avail till I found this:

SET old_passwords = 0; UPDATE mysql.user SET Password = PASSWORD('testpass') WHERE User = 'testuser' limit 1; SELECT LENGTH(Password) FROM mysql.user WHERE User = 'testuser'; FLUSH PRIVILEGES;

Drop that into your mysql client or phpmyadmin and change the testpass to your DB login password and the testuser to your DB login user, execute query. Great success! problem solved.

Gallon answered 28/3, 2011 at 21:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.