LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 06-28-2012, 08:40 PM   #1
dr.trev
LQ Newbie
 
Registered: Apr 2011
Location: Wellington
Distribution: Slackware
Posts: 8

Rep: Reputation: 3
php can't connect to mysql using Pear::MDB2


This is my first LQ post, but I've been using Slackware since around 2000.

A few days back I upgraded to -current (just before the most recent major update), which included httpd-2.4.2-i486-2 and php-5.4.3-i486-3. There were quite a few changes to httpd.conf, which I've integrated into my httpd.conf, but I can't get php to connect to the local mysql database using Pear::MDB2 any more.

The database is working fine, I can log in directly, and the webserver seems to be doing everything else right, but when connecting to mysql I always get
Code:
MDB2 Error: connect failed
I've upgraded from stable to the latest beta MDB2 library, but that didn't help:
Code:
MDB2              2.5.0b3 beta
MDB2_Driver_mysql 1.5.0b3 beta
I'm using the following as my connection string:
Code:
$db_options = array('debug'	=> 2);
$db =& MDB2::factory("mysql://${user}:${pass}@localhost/${db_name}", $db_options);
I've tried loading all the modules I could in httpd.conf, but to no avail, is there some other setting in httpd.conf I need to use to get this to work again? Can anyone give me any more pointers?

Cheers,
Trevor.
 
Old 06-29-2012, 01:50 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu
Posts: 1,426

Rep: Reputation: 100Reputation: 100
if you run
phpinfo()
you may get an idea. Perhaps php is looking for the mysql socket in the wrong directory or something like that?

Hope this helps,
J
 
Old 06-29-2012, 07:55 PM   #3
dr.trev
LQ Newbie
 
Registered: Apr 2011
Location: Wellington
Distribution: Slackware
Posts: 8

Original Poster
Rep: Reputation: 3
Turned out the upgrade to php-5.4.3 meant that the old style mysql passwords (hashes of length 16) were being rejected by php (info found here). The fix was to reset the mysql passwords which rewrites the passwords with hashes of length 41. But first I needed to run mysql_upgrade to fix the privileges table.

Code:
[root@machine]$ mysql_upgrade -p
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysql/mysql.sock' 
Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/var/run/mysql/mysql.sock' 
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.user                                         OK
...
lots of other tables 
...
Running 'mysql_fix_privilege_tables'...
OK
[root@machine]$ mysql -p
mysql> SELECT LENGTH(`password`) FROM mysql.user WHERE user=`user`;  # returns 16
mysql> SET PASSWORD FOR `user`@`localhost` = PASSWORD('blahblah');
mysql> FLUSH PRIVILEGES;
mysql> SELECT LENGTH(`password`) FROM mysql.user WHERE user=`user`;  # returns 41
Problem solved.
 
2 members found this post helpful.
Old 06-29-2012, 08:03 PM   #4
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 227Reputation: 227Reputation: 227
I'm sure I'll run into this with an upgrade I'm planning.

Thanks for posting your solution.
 
Old 06-29-2012, 08:05 PM   #5
dr.trev
LQ Newbie
 
Registered: Apr 2011
Location: Wellington
Distribution: Slackware
Posts: 8

Original Poster
Rep: Reputation: 3
Quote:
Originally Posted by mRgOBLIN View Post
Thanks for posting your solution.
Glad to be of help - especially to a fellow kiwi!!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pear: Cannot connect $db = &MDB2::connect($dsn) st0rmchaser Linux - Software 0 11-11-2011 11:55 PM
GameCP, MySQL, PHP Connect PHP to MySQL? armsman Linux - Software 1 09-15-2011 10:22 AM
Pear MDB2 - mapstorer fruitwerks Programming 0 04-16-2010 02:40 PM
can't connect php to mysql on RHEL5.0 in phpinfo page --without mysql is there vinayakbane Linux - Newbie 1 02-14-2009 11:47 PM
is there a client install for MySql so PHP can connect to MySQL Server? alar Linux - Software 8 07-03-2007 07:42 PM


All times are GMT -5. The time now is 06:53 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration