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);
Related
I'm trying to use the LOAD DATA LOCAL INFILE command in MySQL, but I keep getting an error in PHP/Joomla stating: The used command is not allowed with this MySQL version
I've spent quite a while Googling around, but the only suggestions I've seen involve adding local-infile = 1 to my my.cnf file (which I've already done, in [client], [mysql], and [mysqld]).
Additionally, if I connect from my Apache server to the MySQL server from the command line (so not using PHP), I can run LOAD DATA LOCAL without issue (so it can't be a permissions thing).
I've also checked php.ini, and sure enough, mysqli.allow_local_infile is set to 'On'.
Am I missing something here?
Do you have to do something special in Joomla to make this work correctly?
I just answered a similar question here, maybe it can help:
After going from MySQL 5.0 to 5.5 I found out that I suddenly have to enable LOCAL INFILE specifically when creating the connection in PHP.
Using mysql:
mysql_connect(server,user,code,false,128); // 128 enables LOCAL INFILE
mysql_select_db(database);
Using mysqli:
$conn = mysqli_init();
mysqli_options($conn, MYSQLI_OPT_LOCAL_INFILE, true);
mysqli_real_connect($conn,server,user,code,database);
I ran into the same problem, in my case it was the Joomla user lacking privileges that root has; giving the full privileges to the J user solved it, but then my component is for distribution so I changed to using standard .sql file and parsing / creating them manually. Hope this helps.
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 )
This is how a connection is created to MySQL server at localhost
$Connection = mysql_connect("localhost","root","");
But MySQL seems ignoring my username and password, even if I create the connection with some nonsense username & password:
$Connection = mysql_connect("localhost","nonsense-username","");
Both cases give me the $Connection as "resource(39) of type (mysql link)". And this only happens when password is blank. Is it a default behaviour of MySQL to accept any username when password is blank?
But it is supposed to have $Connection equal 'false' when such 'nonsense-username' given. Anything wrong?
I'm going to assume that you've setup the MySQL server on your own computer, without configuring users, permissions or things like that. If that's the case, then the cause might be SQL Safe Mode. If in your php.ini file, sql.safe_mode is set to 1, then PHP will substitute any arguments you pass to mysql_connect() with their defaults. That would certainly explain this behavior. Try looking at phpinfo() to see if that's the case.
It seems you have not restarted the webserver after install of php-mysql. Please restart the webserver it should work.
I spent two hours debugging that and the simple solution was restart
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
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');