Hi,
I'm trying to get working with PHP 5.3 a legacy web site designed for PHP 4.
It's working OK on PHP 5.2.9 but gives a strange error with 5.3 on Windows
and MySQL on CentOS.
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
The following is the simplest test case that can reproduce the problem on my
machine:
<?php
mysql_connect('host', 'user', 'pass');
mysql_select_db('database');
I assume this has something to do with the new mysqlnd extension, but I
cannot
find how to disable it and enable the old mysql implementation in a
Windows environment
without recompiling PHP itself.
Additional info:
- PHP is running under Windows.
- MySQL server to which I'm trying to connect is on a CentOS box
- I tried connecting to my local database and it worked
- MySQL protocol_version is 10 on both Linux and Windows machines.
- Linux machine MySQL version is 5.0.48
- Windows machine MySQL version is 5.0.67-community-nt
Is there any other MySQL variable that I should look for?
Any feedback appreciated.
--
Ionut G. Stan
I'm under construction |http://igstan.blogspot.com/
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 .
Ulf
--
http://blog.ulf-wendel.de
Artikel zu den Sun MySQL-Connectoren für PHP, C++ und OpenOffice.org
Hi Ulf,
Thanks for the answer, but let me understand this better.
The old mysql API did not support the auth protocol of MySQL 4.1+, but
only lower,
while the new mysqlnd API only supports MySQL 4.1+ auth protocol. At
least this
is what I understand from the error message, your response and the note
on this page[1]
which refers specifically to PHP.
Is that true? If yes, then this should be stressed on the mysqlnd manual
page[2] so that
people can do what suits them best - update passwords or compile PHP
with the MySQL
client library. There are a lot of legacy applications using mysql_*
functions that are working
right now because the auth protocol is the old one (as in my case).
Sorry if I somehow missed such warnings in the manual.
There's also the problem of Windows binaries. Lots of people are
developing on Windows
and host their work where they have little control over the MySQL
configuration. People
compiling PHP on Windows are rare and even some Linux sysadmins are
afraid/don't have
the knowledge to compile PHP with special arguments (my sysadmin). In my
opinion there's
a problem right here that would have been best solved with some php.ini
setting.
Cheers,
[1] http://dev.mysql.com/doc/refman/4.1/en/old-client.html
[2] http://php.net/mysqli.mysqlnd
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 18This 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 .Ulf
--
Ionut G. Stan
I'm under construction | http://igstan.blogspot.com/
Hi,
Ionut G. Stan wrote:
Hi Ulf,
Thanks for the answer, but let me understand this better.
The old mysql API did not support the auth protocol of MySQL 4.1+, but
only lower,
while the new mysqlnd API only supports MySQL 4.1+ auth protocol. At
least this
is what I understand from the error message, your response and the note
on this page[1]
which refers specifically to PHP.
No. libmysql supports both authentication methods, versions of libmysql
4.1+. The old pre-4.1 insecure one and the new post-4.1 secure
authentication. What is different? The password hash in mysql.user is of
a different length. While with the years it has been good to have a
smooth transition, with just a recompile, I think it is high time that
the dbas should secure their systems and change the passwords. In web
environments you don't have too many users, usually just one, which will
need a new password set. Just use the statement for setting the password
and set it to the same as current, then it will work. Also, mysqlnd
doesn't work with servers which are pre-4.1. Windows developers don't
get this as download option at all - mysql 4.0 or 3.2x.x servers.
Is that true? If yes, then this should be stressed on the mysqlnd manual
page[2] so that
people can do what suits them best - update passwords or compile PHP
with the MySQL
client library. There are a lot of legacy applications using mysql_*
functions that are working
right now because the auth protocol is the old one (as in my case).
They are working either because the used libmysql is 3.23, a lpgl one,
or 4.0, because the server used is old. In the case of 4.1, 5.0 and 5.1
servers it is just laziness to change the password. It is written
somewhere in the documentation about upgrading from 4.0 to 4.1.
Sorry if I somehow missed such warnings in the manual.
There's also the problem of Windows binaries. Lots of people are
developing on Windows
and host their work where they have little control over the MySQL
configuration. People
compiling PHP on Windows are rare and even some Linux sysadmins are
afraid/don't have
the knowledge to compile PHP with special arguments (my sysadmin). In my
opinion there's
a problem right here that would have been best solved with some php.ini
setting.
On public hosting it should be very rare to get MySQL Server 4.0 or
earlier. With 4.1 and up everything is fine, just re-set your password.
Cheers,
[1] http://dev.mysql.com/doc/refman/4.1/en/old-client.html
[2] http://php.net/mysqli.mysqlndIonut 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 18This 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 .Ulf
Best,
Andrey
Thanks Andrey, your explanations cleared all my uncertainties.
Hi,
Ionut G. Stan wrote:Hi Ulf,
Thanks for the answer, but let me understand this better.
The old mysql API did not support the auth protocol of MySQL 4.1+,
but only lower,
while the new mysqlnd API only supports MySQL 4.1+ auth protocol. At
least this
is what I understand from the error message, your response and the
note on this page[1]
which refers specifically to PHP.No. libmysql supports both authentication methods, versions of
libmysql 4.1+. The old pre-4.1 insecure one and the new post-4.1
secure authentication. What is different? The password hash in
mysql.user is of a different length. While with the years it has been
good to have a smooth transition, with just a recompile, I think it is
high time that the dbas should secure their systems and change the
passwords. In web environments you don't have too many users, usually
just one, which will need a new password set. Just use the statement
for setting the password and set it to the same as current, then it
will work. Also, mysqlnd doesn't work with servers which are pre-4.1.
Windows developers don't get this as download option at all - mysql
4.0 or 3.2x.x servers.Is that true? If yes, then this should be stressed on the mysqlnd
manual page[2] so that
people can do what suits them best - update passwords or compile PHP
with the MySQL
client library. There are a lot of legacy applications using mysql_*
functions that are working
right now because the auth protocol is the old one (as in my case).They are working either because the used libmysql is 3.23, a lpgl one,
or 4.0, because the server used is old. In the case of 4.1, 5.0 and
5.1 servers it is just laziness to change the password. It is written
somewhere in the documentation about upgrading from 4.0 to 4.1.Sorry if I somehow missed such warnings in the manual.
There's also the problem of Windows binaries. Lots of people are
developing on Windows
and host their work where they have little control over the MySQL
configuration. People
compiling PHP on Windows are rare and even some Linux sysadmins are
afraid/don't have
the knowledge to compile PHP with special arguments (my sysadmin). In
my opinion there's
a problem right here that would have been best solved with some
php.ini setting.On public hosting it should be very rare to get MySQL Server 4.0 or
earlier. With 4.1 and up everything is fine, just re-set your password.Cheers,
[1] http://dev.mysql.com/doc/refman/4.1/en/old-client.html
[2] http://php.net/mysqli.mysqlndIonut 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 18This 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 .Ulf
Best,
Andrey
--
Ionut G. Stan
I'm under construction | http://igstan.blogspot.com/
hi,
By the way, be sure to disable the old authentification method in your
mysql config, centos forces it via a setting in my.cnf. You may also
need to update your password.
Cheers,
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 18This 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 .Ulf
--
http://blog.ulf-wendel.de
Artikel zu den Sun MySQL-Connectoren für PHP, C++ und OpenOffice.org--
--
Pierre