cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting to MySQL

Boxersoft
Rising Star
Posts: 132
Thanks: 20
Fixes: 1
Registered: ‎25-07-2009

Connecting to MySQL

My php code on the ccgi server connects to MySQL on Humbug and works just fine, but I'd like to do some development of the php code running locally before uploading to PlusNet. I've installed WAMP (details below) and got everything running, but when I try running the php locally it fails to connect to MySQL on Humbug with the following error:
Could not connect: mysqlnd cannot connect to MySQL 4.1+ using old authentication

Googling indicates that this is something to do with a change in encoded password lengths in MySQL and (if I understand correctly) the libraries used by more recent versions of php refuse to connect using the shorter ones that seem to be in use on Humbug (SELECT @@global.old_passwords, @@session.old_passwords, Length(PASSWORD('abc') yields 1, 1, 16, and I gather that the 16 would be 41 if longer passwords were in use).
Most of the stuff I read on the web about working around this seems to depend on having more control of MySQL than PlusNet provides (as far as I can tell), and in any case I'm not familiar enough with the workings of php/mysql to go poking around with settings I don't really understand. Is there anything I can do to allow code running in my local php environment to connect to my database on Humbug without the risk of breaking anything running on ccgi?
--------
Local WAMP installation:
PHP Version :5.3.0 
MySQL Client API version mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $
6 REPLIES 6
jojopillo
Plusnet Alumni (retired)
Plusnet Alumni (retired)
Posts: 9,786
Registered: ‎16-06-2010

Re: Connecting to MySQL

Hi Boxersoft,
The only thing I can think is that your version is MySQL5.0 and ours is MySQL4.1
Jojo Smiley
Boxersoft
Rising Star
Posts: 132
Thanks: 20
Fixes: 1
Registered: ‎25-07-2009

Re: Connecting to MySQL

Hi Joanne. Yes, my version of MySQL is later than yours - but it's yours that I'm trying to connect to. Is there something I have to do to allow my installation of php5 to talk to MySQL 4.1, as your php5.x does?
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: Connecting to MySQL

I think the problem is that the MySQL interface in PHP 5.3 changed to use the longer password format that MYSQL 4.1 and later will support but the Plusnet servers are still old format (as required up to PHP 5.2).
To achieve your primary aim installing an older version of WAMP with PHP 5.2 is probably the simplest solution. Perhaps WampServer2.0h which you can download from SourceForge?
David
David
Boxersoft
Rising Star
Posts: 132
Thanks: 20
Fixes: 1
Registered: ‎25-07-2009

Re: Connecting to MySQL

That makes sense, thanks. Downgrading to php5.2 is an option, I guess. I got the impression that there might be a way to work around the issue by setting @@session.old_passwords or something but I don't know if that's possible with the PlusNet setup. Not knowing the potential repercussions, I didn't want to fiddle with such things without advice.
Thanks for the comments.
spraxyt
Resting Legend
Posts: 10,063
Thanks: 674
Fixes: 75
Registered: ‎06-04-2007

Re: Connecting to MySQL

My thoughts were that using an older version of PHP (5.2) in your WAMP installation is consistent with the current ccgi version for one thing, but most importantly respects the "without risk of breaking anything on ccgi" requirement.
David2
David
Boxersoft
Rising Star
Posts: 132
Thanks: 20
Fixes: 1
Registered: ‎25-07-2009

Re: Connecting to MySQL

Indeed so. Thanks.