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?
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.
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;
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
Related
Standard error with no solution for my own case:
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 [2000]
I have googled enough, trying different advices, but I still don't know what to try now, because I do such a query in MySQLManager:
SELECT LENGTH(Password) FROM mysql.user;
show variables like 'old_passwords';
and I got such a answer:
LENGTH(Password)
41
41
41
old_passwords: OFF
It seems to be right hash method for passwords (not 16), right old_password value (OFF), but I can't fix the error and even don't know what more I should try.
I use OpenServer 5.2.2, with:
DB Server:
Server: 127.0.0.1 via TCP/IP
Server type: MySQL
Server version: 5.5.45 - MySQL Community Server (GPL)
Protocol version: 10
User: max#localhost
Server coding: UTF-8 Unicode (utf8)
Web-Server:
Apache/2.2.31 (Win32)
Version client DB: libmysql - mysqlnd 5.0.8-dev - 20102224
PHP extension: mysqli
UPD: Can old-version php code encrypt password in old 16-bit code? Maybe this is the reason?
Not solved, but got round - I've done export DB from site source DB with unchecked option "save binary fields in hexadecimal", downloaded new version of php site - then wrote right user and password, and all worked properly
I know that there have been a lot of questions raised with the same concern as mine, but I hope you can help me find out another solution for this.
We are using Symfony 2.5.10, PHP 5.4.44 and MySQL 4.1.20 for our project.
Whenever I attempt to log in to the system or any act that concerns connecting to the database (e.g adding new user using FOS commands), I receive this error:
SQLSTATE[HY000] [2000] 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
We already tried setting old_passwords in my.cnf to 0, restart mysql, set a new password for the mysql user and restart mysql again but still the same. And whenever we run this in the query window:
SELECT user, Length(Password) FROM mysql.user;
it still shows 16 as the length of the password of the user we are using. And also when checking the mysql server variables and settings, old passwords is ON (even though we already set old_password to 0 in my.cnf).
What could be wrong with this? I would really appreciate your help.
Update: For the meantime, we remove the db user's password for us to be able to access the database. But I'm still looking for other solutions since those solutions I found on the net (like removing or commenting out old_passwords=1 in my.cnf, setting old_passwords to 0 and setting new password then restart) didn't work for me.
Another Update: Commonly, the solution for this problem would be setting old_passwords off in mysql but then, as mentioned in the PHP documentation,
the new mysqlnd library does not read mysql configuration files (my.cnf/my.ini).
So does this mean that setting old_passwords to in 0 in my.cnf has no use? I still haven't figure out solution to this problem.
Do we need an upgrade in any of the platforms used? Thanks in advance for the help.
"SET PASSWORD" is deprecated in MySQL server 5.7.6.
The syntax to be followed for servers below 5.7.6 is,
SET PASSWORD [FOR user] = password_option
password_option: {
PASSWORD('auth_string')
| OLD_PASSWORD('auth_string')
| 'hash_string'
}
The syntax to be followed for servers 5.7.6 and above is,
SET PASSWORD [FOR user] = password_option
password_option: {
PASSWORD('auth_string')
| 'auth_string'
}
Also refer-> http://dev.mysql.com/doc/refman/5.7/en/set-password.html
Please try this solution
http://laravel.io/forum/04-16-2014-solving-mysqlnd-cannot-connect-to-mysql-41
As per the solution you just need to set the password again and specify that it be saved in the new format.
mysql> SET ##session.old_passwords = 0;
Query OK, 0 rows affected (0.00 sec)
SET PASSWORD FOR 'existinguser'#'localhost' = PASSWORD('existingpass');
Query OK, 1 rows affected (0.00 sec);
I am trying to install wordpress into my system at fedora 17. I am getting error with database connectivity:
Error establishing a database connection
I have done below troubleshooting.
I have tried with command prompt to connect mysql database with same credentials and its connected successfully.
Than I tried to connect to database directly using php using below code.
<?php
$db = #mysql_connect('localhost', 'wpuser', 'wppassword');
if (!$db) echo "connection failed --". mysql_error();
else echo "connection succeeded";
?>
I received error:
connection failed --No such file or directory
Than I have recompiled php with apache2 and mysql than the same code is throwing error:
connection failed --The server requested authentication method umknown to the client
mysql conf file is as below.
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
also at php.ini I have set
mysql.default_socket = /var/lib/mysql/mysql.sock
Please let me know how to proceed further.I am still getting the same error for wordpress.
The first error
No such file or directory
is because of the path to mysqld.sock file is wrong. This probably has been fixed as you state later that another error you recieve is
The server requested authentication method unknown to the client
This error has been explained here on ServerFault
MySQL introduced longer password hashes in (i think) version 4.1, and
your server probably still uses them (check for 16 byte password
hashes in your mysql user table). Newer versions use longer password
hashes. Your server supports both, but your client (php) seems to
support only new ones in this version (and on).
If it's possible, use the solution from the link in the first line,
and set your password again with the new hash, but beware, if you're
using any other (old) clients which rely on old passwords,
compatibility might break. Also try looking for old-password support
for MySQL in PHP, but i'm not sure about it.
I just upgraded my developement box's PHP to the latest version, 5.4.5. This developement machine connects to a remote MySQL server, residing on a shared server that I lease from a hosting company.
Trying to connect to my remote MySQL server using simple mysql_connect('myserver.com', 'user', 'password') results in the following error:
Warning: 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 file.php on line 2
Simply, as advised, just executing:
SET PASSWORD = PASSWORD('my-password');
wouldn't change anything.
The same applies when executing
SET SESSION old_passwords=FALSE;
After a bit of searching, I realized that I needed quite deep access to the MySQL server to be able to fix this problem, which I do not have. Trying to execute this query:
UPDATE mysql.user SET Password=PASSWORD('my-password')
WHERE User='my_user' AND Host='my-server';
FLUSH PRIVILEGES;
Simply gives me the following error:
1142 - UPDATE command denied to user 'u0112918'#'www10.aname.net' for table 'user'
Requests to have the company execute the query for me has, so far, been unsuccessfull. So my question is if there's any way to fix this on the client side, without involving 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 )
I just updated php to 5.3 and can no longer connect to my remote mysql server. I get the following errors:
mysqli_connect(): OK packet 6 bytes shorter than expected
mysqli_connect(): (HY000/2000): mysqlnd cannot connect to MySQL 4.1+ using old authentication
It seems this has to do with the new mysqlnd driver. Is there a way to force it to use the old libmysql driver. Also, reverting to php5.2.11 doesn't seem to fix the issue which seems to work for most people.
Well I typed up a long cool response but someone better than me already has answered it. The tldr; of this response is recompile your php for your application.
http://news.php.net/php.internals/43535
Ionut G. Stan schrieb:
Warning: mysql_connect() [function.mysql-connect]: OK packet 6 bytes
shorter than expected in {filename} on line 18
Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot
connect to MySQL 4.1+ using old authentication in {filename} on line 18
This says everything. You cannot use old authentication with mysqlnd.
Upgrade you server passwords to the more recent and more secure
authentication method or recompile PHP with libmysql (MySQL Client
Library) support. Check ./configure --help | grep -C3 mysql and
http://www.php.net/manual/en/mysql.installation.php .
http://dev.mysql.com/doc/refman/5.1/en/old-client.html says:
Reset the password to pre-4.1 style for
each user that needs to use a pre-4.1
client program. This can be done using
the SET PASSWORD statement and the
OLD_PASSWORD() function:
mysql> SET PASSWORD FOR
-> 'some_user'#'some_host' = OLD_PASSWORD('newpwd'); Alternatively,
use UPDATE and FLUSH PRIVILEGES:
mysql> UPDATE mysql.user SET Password
= OLD_PASSWORD('newpwd')
-> WHERE Host = 'some_host' AND User = 'some_user'; mysql> FLUSH
PRIVILEGES; Substitute the password
you want to use for “newpwd” in the
preceding examples. MySQL cannot tell
you what the original password was, so
you'll need to pick a new one.
Tell the server to use the older
password hashing algorithm:
Start mysqld with the --old-passwords
option.
There are many more options on this page....
See this.
Just reset the user's password.
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('mypassword');