Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 25th May 2007, 22:33
swggy swggy is offline
Junior Member
 
Join Date: May 2007
Posts: 11
Thanks: 5
Thanked 0 Times in 0 Posts
Default The classic MySQL connect error

Newbie speaking…

I've followed the 'perfect setup for CentOS 5.0' and I've got everything running fairly well. However, I can't fire up my test MySQL script - I get
Quote:
Fatal error: Call to undefined function mysql_connect() in /var/www/web8/web/.../mysql_up.php on line 12
So I went to the search engine and found 42,900 occurrences of this. I've poked around in the forums and found near hits to answer my problem, but nothing exact - one of the problems I'm bumping into is that so many of the answers presume that PHP is running on Windows, which doesn't really help me.

* I understand that MySQL isn't turned on by default in PHP5.
* I understand that MySQL is loaded on my system, since I'm running ISPConfig and it uses MySQL.
* I understand that my PHP probably doesn't have MySQL installed as an extension, since phpinfo says
Quote:
'--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd'
and there's no table further down for it (I rather thought that 'the perfect setup' for a LAMPS install would automatically have php with MySQL, but that's another story.)

So I'm wondering - how to activate MySQL in PHP5, and it seems as if I have to recompile PHP. I’ve got 3 questions:

1) I’m guessing that I can take the entire configure command in the big box at the top of the phpinfo() display and run that (tweaking the ‘-–without-mysql’ of course). True?
2) What directory do I run this from? There’s a pile of ‘.h’ files in ‘/usr/include/php/main’ - do I go there? Or where?
3) Do I need anything else?

Thanks for any help ...
swggy
Reply With Quote
Sponsored Links
  #2  
Old 26th May 2007, 15:29
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,409
Thanks: 834
Thanked 5,496 Times in 4,326 Posts
Default

Quote:
1) I’m guessing that I can take the entire configure command in the big box at the top of the phpinfo() display and run that (tweaking the ‘-–without-mysql’ of course). True?
No. Mysql is compiled fine. What all the sources you found in the internat take not in account that today all php installations are compiled modular, so --without-mysql just means that mysql is loaded as module and not compiled in.

Quote:
2) What directory do I run this from? There’s a pile of ‘.h’ files in ‘/usr/include/php/main’ - do I go there? Or where?
Do not do this if you dont want to mess up your installation!

Quote:
3) Do I need anything else?
Yes

1) Make sure that you have the php mysql module installed:

yum install php-mysql

If the command says that it is already installed, you must check if the module is loaded. Have a look at the php.ini file, the file is most likely in /etc/php5/apache2/ php.ini or a similar location in the /etc directory.

There must be a line in the file like:

extension=mysql.so

if you do not have this line, add it at the end of the file and restart your apache webserver.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 26th May 2007, 18:04
swggy swggy is offline
Junior Member
 
Join Date: May 2007
Posts: 11
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Thanks, but that didn't fix it ...
  • I did 'yum install php-mysql' and got back 'nothing to do'.
  • Then I found that mysql.so wasn't in the ini file, so I added 'extension=mysql.so' to the bottom of the file as you said, but nothing changed.
  • I then tried moving it to the extensions area instead, but nothing.
  • I also tried adding mysqli.so there, since I'm reading that PHP5 takes mysqli instead of mysql, but nothing.

I can get in through Putty on the CLI with
Quote:
mysql --user=swggy test
...of course that's not PHP, but it does confirm that the username and no pwd gets access.

phpinfo says my config file is /etc/php.ini (which is the file I've been making your changes to), and it says that 'extension_dir=./' - is that OK? The tables at the bottom of the phpinfo report jump straight from 'mime_magic' to 'openssl', so adding the 'extension=mysql.so' doesn't seem to have had any effect...
I also see that I have the following in /usr/lib/php/modules:
Quote:
file:///usr/lib/php/modules/dom.so
file:///usr/lib/php/modules/gd.so
file:///usr/lib/php/modules/imap.so
file:///usr/lib/php/modules/ldap.so
file:///usr/lib/php/modules/mysqli.so
file:///usr/lib/php/modules/mysql.so
file:///usr/lib/php/modules/odbc.so
file:///usr/lib/php/modules/pdo_mysql.so
file:///usr/lib/php/modules/pdo_odbc.so
file:///usr/lib/php/modules/pdo.so
file:///usr/lib/php/modules/pdo_sqlite.so
file:///usr/lib/php/modules/phpcups.so
file:///usr/lib/php/modules/xmlreader.so
file:///usr/lib/php/modules/xmlrpc.so
file:///usr/lib/php/modules/xmlwriter.so
file:///usr/lib/php/modules/xsl.so
So I may be a little further, but not there yet. Any other thoughts?
- thanks.
Reply With Quote
  #4  
Old 29th May 2007, 15:51
pyro pyro is offline
Junior Member
 
Join Date: Apr 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i have same problem on perfect suse 10.2
isconfig is working, phpmyadmin is working - all users can login and root has all mysql privileges but when i test script to connect mysql then there is mysql_connect error message...
Reply With Quote
  #5  
Old 29th May 2007, 21:47
swggy swggy is offline
Junior Member
 
Join Date: May 2007
Posts: 11
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Contrary to your response, the PHP site itself here... http://us2.php.net/mysql says clearly that for PHP 5 on a Linux OS, PHP needs to be reconfigured before MySQL is supported:
Quote:
PHP 5+

MySQL is not enabled by default, nor is the MySQL library bundled with PHP. Read this FAQ for details on why. Use the --with-mysql[=DIR] configure option to include MySQL support. You can download headers and libraries from » MySQL.
Are you wrong? Are they wrong? Am I missing something? Everything still seems to point to the need to reconfigure with the MySQL optin turned on. I just don't have an answer yet. Maybe I need to ask on another forum?
Reply With Quote
  #6  
Old 29th May 2007, 22:03
swggy swggy is offline
Junior Member
 
Join Date: May 2007
Posts: 11
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Pyro - once I get a response that fixes my problem I'll post it.
Reply With Quote
  #7  
Old 29th May 2007, 22:42
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,409
Thanks: 834
Thanked 5,496 Times in 4,326 Posts
Default

Quote:
Are you wrong?
No.

Quote:
Are they wrong?
No.

Quote:
Am I missing something?
Yes. You neither read what I said not what they said properly. php.net is talking about statically compiled in mysql support which is not used anymore in most linux distributions. They all use modular PHP now where the mysql module is loaded in form of a mysql.so file.

But if you want to mess up your setup, please recompile it.

Please post the output of:

locate php.ini

Also set:

extension_dir=/usr/lib/php/modules

in all php.ini files that you find in /etc and its subdirectories.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
swggy (29th May 2007)
  #8  
Old 29th May 2007, 22:44
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,409
Thanks: 834
Thanked 5,496 Times in 4,326 Posts
Default

Quote:
i have same problem on perfect suse 10.2
isconfig is working, phpmyadmin is working - all users can login and root has all mysql privileges but when i test script to connect mysql then there is mysql_connect error message...
run:

yast -i php-mysql
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #9  
Old 29th May 2007, 23:09
swggy swggy is offline
Junior Member
 
Join Date: May 2007
Posts: 11
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Here's the output - it's only in /etc
Quote:
[root@server ~]# locate php.ini
/etc/AAAphp.ini
/etc/php.ini
/etc/php.ini~
/root/.kde/share/apps/RecentDocuments/php.ini.desktop
/root/ispconfig/php/php.ini~
/root/ispconfig/php/root%2fispconfig%2fphp%2fphp.ini.old
... and hey, presto, changing 'extension_dir=./' to 'extension_dir=/usr/lib/php/modules' did the trick.

Don't be too grumpy with the newbie - I'm vey grateful.

Thanks.
Reply With Quote
  #10  
Old 30th May 2007, 13:25
pyro pyro is offline
Junior Member
 
Join Date: Apr 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

yess- extension_dir=/usr/lib/php5/modules did the trick.


tnx'!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
configuring IPTABLES firewall adityavpratap HOWTO-Related Questions 9 27th May 2006 21:42
Frustrated with ISPConfig install! woozyerdaddee Installation/Configuration 4 19th May 2006 03:38
Fresh Install on Debian cksrealm Installation/Configuration 12 22nd February 2006 16:14
Installation Fails... :( cyberstorm Installation/Configuration 1 15th January 2006 18:07
Install stop at uuwish, UUDeview SeaWolf Installation/Configuration 6 4th October 2005 23:53


All times are GMT +2. The time now is 16:56.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.