PHP 5.4 Pdo Could Not Connect to MySQL 4.1+ Using the Old Insecure Authentication

PHP 5.4 PDO could not connect to MySQL 4.1+ using the old insecure authentication

SOLVED!

Although the SET SESSION old_passwords=0; wasn't working in phpMyAdmin.

I downloaded the MySQL GUI Tools and used the MySQL Query Browser to execute the same command on non-DBO user:

SET SESSION old_passwords = 0;

SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc'));

now returned:

1      0      41

So I simply changed the password:

SET PASSWORD = PASSWORD('my_old_password')

And now PHP 5.4 PDO connects to the database with that user!

mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication

Figured it out! Was an oversight on my part. Apparently, in ZenCart there are 2 files where you have to set your database configuration. One is for the catalog and one for the admin area. Doesn't make a whole lot of sense to me since both of them connect to the same DB. Maybe it has something to do with being able to use one db user for the catalog and one for the admin for security reasons. I just setup a local copy and changed one of the config files without changing the other. The file causing the problems was still pointed at my production database. Knew it had to be something simple!

Cannot connect to MySQL 4.1+ using old authentication

edit: This only applies if you are in control of the MySQL server... if you're not take a look at Mysql password hashing method old vs new

First check with the SQL query

SHOW VARIABLES LIKE 'old_passwords'

(in the MySQL command line client, HeidiSQL or whatever front end you like) whether the server is set to use the old password schema by default. If this returns old_passwords,Off you just happen to have old password entries in the user table. The MySQL server will use the old authentication routine for these accounts. You can simply set a new password for the account and the new routine will be used.

You can check which routine will be used by taking a look at the mysql.user table (with an account that has access to that table)

SELECT `User`, `Host`, Length(`Password`) FROM mysql.user

This will return 16 for accounts with old passwords and 41 for accounts with new passwords (and 0 for accounts with no password at all, you might want to take care of those as well).

Either use the user management tools of the MySQL front end (if there are any) or

SET PASSWORD FOR 'User'@'Host'=PASSWORD('yourpassword');
FLUSH Privileges;

(replace User and Host with the values you got from the previous query.) Then check the length of the password again. It should be 41 now and your client (e.g. mysqlnd) should be able to connect to the server.

see also the MySQL documentation:
* http://dev.mysql.com/doc/refman/5.0/en/old-client.html

* http://dev.mysql.com/doc/refman/5.0/en/password-hashing.html

* http://dev.mysql.com/doc/refman/5.0/en/set-password.html

Error: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication

  • Remove or comment old_passwords = 1 in my.cnf

Restart MySQL. If you don’t, MySQL will keep using the old password format, which will mean that you cannot upgrade the passwords using the builtin PASSWORD() hashing function.

The old password hashes are 16 characters, the new ones are 41 characters.

  • Connect to the database, and run the following query:

    SELECT user, Length(`Password`) FROM  `mysql`.`user`;

This will show you which passwords are in the old format, e.g.:


+----------+--------------------+
| user | Length(`Password`) |
+----------+--------------------+
| root | 41 |
| root | 16 |
| user2 | 16 |
| user2 | 16 |
+----------+--------------------+

Notice here that each user can have multiple rows (one for each different host specification).

To update the password for each user, run the following:

UPDATE mysql.user SET Password = PASSWORD('password') WHERE user = 'username';

Finally, flush privileges:

FLUSH PRIVILEGES;

Source: How to fix "mysqlnd cannot connect to MySQL 4.1+ using old authentication" on PHP5.3

PHP 5.4 old auth on shared server, fixing without editing the mysql server

Hm, try executing the following query through a tool other then PhpMyAdmin, such as Mysql Workbench or through a shell:

SET SESSION old_passwords=0; 
SET PASSWORD = PASSWORD('passwordString');

You should be allowed to change your own password without DML Rights on user-table.

Edit: since it did not resolve the issue - when "read_only" is enabled for the database then you need super rights to change (even your own) password ( http://dev.mysql.com/doc/refman/5.5/en/set-password.html )



Related Topics



Leave a reply



Submit