Yunus Eren Güzel
Yunus Eren Güzel

Reputation: 3088

Mysql password Error in PHP

When i try to connect a remote mysql server from my localhost i get this error:

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

Any idea why it gives this error?

Upvotes: 1

Views: 7933

Answers (3)

aqm
aqm

Reputation: 3034

this helped me

http://www.phpro.org/articles/Database-Connection-Failed-Mysqlnd-Cannot-Connect-To-MySQL.html

quick fix

as db user

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

as admin

FLUSH PRIVILEGES;

real fix

open up your my.conf file and comment out the following line

old_passwords=1

Restart MySQL. this will ensure MySQL never uses the old passwords again.

as db user

SET PASSWORD=PASSWORD('my_password');

as admin

FLUSH PRIVILEGES;

Upvotes: 1

satnhak
satnhak

Reputation: 9861

It seems to be an issue when running PHP <=5.2 code in PHP 5.3+: http://forums.mysql.com/read.php?52,403493,411125#msg-411125

Upvotes: 0

Pascal MARTIN
Pascal MARTIN

Reputation: 401002

It gives this error because your MySQL server uses the old way of storing password -- and not the new way, which is more secure.

The mysqlnd driver, which has been introduced with PHP 5.3, doesn't support the old authentication way.

So, you have to modify your MySQL configuration, to use the new, more secure way.
The error message you get is indicating you how to do that.

Upvotes: 4

Related Questions