Domanda

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
È stato utile?

Soluzione

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/

Altri suggerimenti

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.

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

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top