"Could not connect to database", but I can

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
prost

"Could not connect to database", but I can

Post by prost »

When the option "Create Tables" is checked, I get an error message in step 4 of the install script: "Could not connect to database. Verify that username and password are correct, and that the user has access to the given database." I've verified (using a cli mysql client) that the database exists and the user (who's been granted all privileges) can create tables and insert data.

details: CMSMS 1.0.2, PHP 4.4.1, MySQL 4.1.12, Mac OS X 10.3.9

What might be wrong?

Note: in step 1 the install script does warn about the 8M PHP memory limit, which according to some posts here seems a potential cause. I've tried upping that to 16 MB in php.ini (and restarted apache), but this seems to be ignored. Looks like my PHP install was compiled without  --enable-memory-limit. Before I go recompile PHP I'd rather be sure that this will indeed solve the "could not connect to database" error. Especially because this install attempt is just a quick local test, in order to be able to tell my web hoster what exactly I'll need from him to be able to run CMSMS.

TIA
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: "Could not connect to database", but I can

Post by Dee »

It could very well be that PHP runs out of memory when it's trying to create the ADOdb connection object.
Only other thing I can think of is maybe some strange characters in the username or password.

Either way I wouldn't recommend running 1.0.2 with less than 12 or 16M memory_limit.

You can use the phpinfo() function to check compile flags, memory limit and the php.ini used.
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: "Could not connect to database", but I can

Post by tsw »

and you might want to check that the sql server user has rights to connect from the www server address (if both www and sql server are on the same machine it should be fine)
prost

Re: "Could not connect to database", but I can

Post by prost »

Dee wrote: Only other thing I can think of is maybe some strange characters in the username or password.
No strange characters. Plain ascii, no spaces etc.
Dee wrote: You can use the phpinfo() function to check compile flags, memory limit and the php.ini used.
PHP was compiled without  --enable-memory-limit, the memory limit as reported by CMSMS' install script is 8M (I don't know of another method to verify this, since memory_get_usage() is only available when PHP is compiled with --enable-memory-limit) and I'm sure I am using the right php.ini file.
tsw wrote: and you might want to check that the sql server user has rights to connect from the www server address (if both www and sql server are on the same machine it should be fine)
Both run on the same server and are used by a few other PHP&MySQL based sites. So that's definitely not the issue

Might there be a workaround, instead of having to recompile PHP? I can recompile PHP on my own server, but getting the average hosting company to offer PHP with a 16MB memory limit will be a challenge. Based on the hosters I use at the moment, it seems common to offer a PHP compiled without --enable-memory-limit, so even if I'd recompile PHP on my test server, for production I'll be stuck with an 8MB limit anyway, or need to find a new hoster.

I'm willing to hack the install script, for instance to have it load fewer modules and then add them later again, if that would likely solve this. I'm not willing to learn the entire CMSMS source code just to get it installed :)
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: "Could not connect to database", but I can

Post by tsw »

on line 770 in installer.php there is a debug flag for adodb connections, actually you might want to move it above $db = ADONewConnetion stuff and uncomment it.
Dee
Power Poster
Power Poster
Posts: 1197
Joined: Sun Mar 19, 2006 8:46 pm

Re: "Could not connect to database", but I can

Post by Dee »

prost wrote: Might there be a workaround, instead of having to recompile PHP? I can recompile PHP on my own server, but getting the average hosting company to offer PHP with a 16MB memory limit will be a challenge. Based on the hosters I use at the moment, it seems common to offer a PHP compiled without --enable-memory-limit, so even if I'd recompile PHP on my test server, for production I'll be stuck with an 8MB limit anyway, or need to find a new hoster.
I think you should find a new hoster if you can't increase memory_limit to more than 8M, because there's a large chance you'll get into trouble running CMSMS with a 8M limit.
I'm on relatively cheap hosting (€ 24,99 a year) which has memory_limit set to 32M by default.
Many hosters allow you to override php.ini settings (memory_limit also) using a .htaccess file.
prost wrote: I'm willing to hack the install script, for instance to have it load fewer modules and then add them later again, if that would likely solve this. I'm not willing to learn the entire CMSMS source code just to get it installed :)
To install CMSMS with fewer core modules loaded, simply delete their folders from the modules folder and install CMSMS, then upload the modules after installing CMSMS and install them from the modules page in the admin.
Last edited by Anonymous on Tue Sep 26, 2006 2:17 pm, edited 1 time in total.
prost

Re: "Could not connect to database", but I can

Post by prost »

Dee wrote: I think you should find a new hoster if you can't increase memory_limit to more than 8M, because there's a large chance you'll get into trouble running CMSMS with a 8M limit.
I'm on relatively cheap hosting (€ 24,99 a year) which has memory_limit set to 32M by default.
OK, I'll consider changing to a better hoster then :)
Dee wrote: To install CMSMS with fewer core modules loaded, simply delete their folders from the modules folder and install CMSMS, then upload the modules after installing CMSMS and install them from the modules page in the admin.
Thanks. I tried. Deleted some modules, deleted more modules, and deleted all modules. Still get the same "could not connect to database" error.

Does this suggest the problem might be something else than the 8MB PHP memory-size limit, or just that even without the default modules the install script still needs more than 8MB?
prost

Re: "Could not connect to database", but I can

Post by prost »

Dee wrote: It could very well be that PHP runs out of memory when it's trying to create the ADOdb connection object.
Only other thing I can think of is maybe some strange characters in the username or password.
Update: I installed MySQL 5.0.24a and PHP 5.1.4 (also compiled without --enable memory-limit) on another machine (running Mac OS X 10.4.7) and lo and behold, CMSMS' install script ran without a hitch -- In spite of the 8M memory limit. I used the exact same database name, username and password, with the same permissions (ALL on databasename.*).

So it seems unlikely that the "Could not connect to database" error on the first machine is caused by the 8M memory-limit. But then what might be the cause...?
Locked

Return to “[locked] Installation, Setup and Upgrade”