Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Admin: Unable to connect to database server


monstredeminuit

Recommended Posts

Hi all,

I have been running successfuly OsCommerce for a few months now.

I have installed a few contribs and modded the shopping cart to my needs and it worked quite well.

 

Recently, I tried to install the contrib CCGV (discount coupons and gift vouchers). Whatever I tried, it wouldn't work at the checkout page, returning a white page. I proceeded to re-upload my backed-up php files. It worked, but at checkout I had errors showing up about coupon data missing. Oups...

 

I tried to work around that a few times, but now for no apparent reason (to me anyway) I can't connect to the database anymore when I try to login the admin section. I get the error message in black text "Unable to connect to database server!" on white page.

 

I tried restoring yesterday's mysql database I had backed up, but I get the same error message.

 

Hmmm.... Any idea why the admin pannel cannot connect to the database, but I still see all the items when I surf on the store?

 

Thank you...

Link to comment
Share on other sites

the error is from:

 

// make a connection to the database... now

tep_db_connect() or die('Unable to connect to database server!');

 

so it looks like your admin/includes/configure.php got messed up

 

compare it with catalog/includes/configure.php in the following areas:

(this is from the install file)

 

define('DB_SERVER', '');

define('DB_SERVER_USERNAME', 'mysql');

define('DB_SERVER_PASSWORD', '');

define('DB_DATABASE', 'osCommerce');

 

those lines should be the same, using the catalog/includes/configure.php ones as the correct ones

Link to comment
Share on other sites

the error is from:

 

// make a connection to the database... now

tep_db_connect() or die('Unable to connect to database server!');

 

so it looks like your admin/includes/configure.php got messed up

 

compare it with catalog/includes/configure.php in the following areas:

(this is from the install file)

 

define('DB_SERVER', '');

define('DB_SERVER_USERNAME', 'mysql');

define('DB_SERVER_PASSWORD', '');

define('DB_DATABASE', 'osCommerce');

 

those lines should be the same, using the catalog/includes/configure.php ones as the correct ones

 

------------------

 

Where else might OSC be getting the username and password from?

 

I just took over someone else's site. My server admin issued me new usernames and passwords, and they work fine from PHP Admin - but they broke the database connection of OSC. I can get into the database just fine using phpAdmin, But OSC cannot establish the connection. It continues to try and use the moonpie_0-admin login, not the moonpie_0-all or -ro or -rw logins they gave me.

MUST I have a user named "(databasename)-admin"?

 

I have exactly the same info in BOTH copies of configure.php as you explained above. And the login/pwd set works fine from phpAdmin, but OSC cannot connect to the database.

 

Where else do I need to update the login info besides the two configure.php scripts?

And, does OSC *require* the user id to be *"-admin"?

 

Thanks

Alan

Link to comment
Share on other sites

Where else might OSC be getting the username and password from?

FYI - Here are the contents of my edited configure.php:

(Note: I have replaced the host's name with (hostname) in the code snippet below for purposes of illustration)

// define our database connection
 define('DB_SERVER', 'custsql.sonic.net'); // eg, localhost - should not be empty for productive servers
//  define('DB_SERVER_USERNAME', 'moonpie_0-admin');
//  define('DB_SERVER_PASSWORD', 'oB2KFW');
// changed by alan 11/17/06
 define('DB_SERVER_USERNAME', 'moonpie_0-all');
 define('DB_SERVER_PASSWORD', '3c2d99b2');
 define('DB_DATABASE', 'moonpie_0');
 define('USE_PCONNECT', 'false'); // use persistent connections?

 

But the error I get continues to refer to the -admin login...

 

Warning: mysql_connect(): Access denied for user 'moonpie_0-admin'@'eth1.ssl.(hostname).net' (using password: YES) in /nfs/ssl-htdocs/moonpie/catalog/includes/functions/database.php on line 19
Unable to connect to database server!

Link to comment
Share on other sites

if you can access the database thru cPanel (or other program), go there and add an additional new user to the database.

 

For cPanel, you will create a user/password, then you will assign that user to the database.

It is a two step process.

 

Then change the info in both configure files to reflect the new info

 

That should do it

 

(if you wonder why this error is, my guess is you are missing a prefix to the user or pw even though you access the db w/o a prefix)

Link to comment
Share on other sites

if you can access the database thru cPanel (or other program), go there and add an additional new user to the database.

 

For cPanel, you will create a user/password, then you will assign that user to the database.

It is a two step process.

 

Then change the info in both configure files to reflect the new info

 

That should do it

 

(if you wonder why this error is, my guess is you are missing a prefix to the user or pw even though you access the db w/o a prefix)

Thanks, but... No Cpanel on this server - and we do have 3 new user names and passwords - and they do work to acess the database via phpAdmin. But what is this about a prefix? Never heard of that. The old configure.php shows the old user name 'moonpie_0-admin', and my new syntax is identical.

 

The question is "Where is OSC getting this 'admin' reference from?" It must be reading some other configuration file besides the two edited configure.php files I have already dealt with...

 

But I can't find them or any reference to anything other than configure.php. Isn't there supposed to be an .ini file someplace? Can't find that anywhere in the file system...

 

-in a cyber-space quandry..

Link to comment
Share on other sites

ok it looks like "moonpie_ " is the prefix - this is put in by the DB user/pw generator

 

I know this may sound strange, but try changing the user name to this:

 

"0-admin"

 

that is without the prefix, I have a few servers and one will only work this way...go figure

Link to comment
Share on other sites

ok it looks like "moonpie_ " is the prefix - this is put in by the DB user/pw generator

 

I know this may sound strange, but try changing the user name to this:

 

"0-admin"

 

that is without the prefix, I have a few servers and one will only work this way...go figure

Thanks for your help. Yes. It does seem that the database name is prepended to the selected user name.

But now the story changes a bit...

Actually, it turns out that the database connection from OS Commerce IS working for most features now that I have synched the two configure.php scripts.. I can manage the database and view items, etc. from the Admin System.

And now, the error ONLY appears now when I select the option to "View Account" from within the shopping cart. (But I made no other changes to ANYTHING other than the two configure.php files....

The ssl link to "My Account" is the procedure that is still trying to log in as 'admin"...

Warning: mysql_connect(): Access denied for user 'moonpie_0-admin'@'eth1.ssl.(hostname).net' (using password: YES) in /nfs/ssl-htdocs/moonpie/catalog/includes/functions/database.php on line 19
Unable to connect to database server!

.

So. Why does this one function STILL think the database user is admin when OSC Admin now works for user "moonpie_0-all"???

 

There's got to be some other config info stored somewhere, or something in some ssl long-term cache. Only I can't image where it is...

 

Any ideas?

Link to comment
Share on other sites

And, one more thing. the error also shows up when I select "checkout".

so. "My Account" and "Checkout" both try to access the db using user 'moonpie_o-admin".

I'll try shutting down my connection, do that MS thing and close all the windows and shut down. then I'll disable the DSL line and reconnect with a new IP addr and see what happens then...

Link to comment
Share on other sites

And, one more thing. the error also shows up when I select "checkout".

"My Account" and "Checkout" both try to access the db using user 'moonpie_o-admin".

I'll try shutting down my connection, do that MS thing and close all the windows and shut down. then I'll disable the DSL line and reconnect with a new IP addr and see what happens then...

Resetting my system, cookies and IP address made no difference at all. I can access MySQL through phpAdmin, I can access the database through the OSC Admin page, but customers cannot access their accounts, nor place orders. My client is very stressed and I am confused myself, not knowing just WHERE the MyAccount and Checkout routines get the database connection info... nor why the system is broken...

 

Thanks in advance for any insight anyone may have on this database access/OSC configuration question....

- Alan :'(

Link to comment
Share on other sites

More news on this matter.

 

It appears that the problem lies within an ssl connection to the site. The errors only show up on pages linked via https:// The pages that do not employ ssl read the configuration properly, display as they should and do not eror out. Is it common - or possible - that our host has another set of configure.php or database.php stored somewhere beyond my reach? That the there are more files that need to be updated?

 

- Alan

Link to comment
Share on other sites

There are no other places that have the db user info

 

I suggest that you do the following:

 

make a new user and new password for the database with ALL privileges

 

then change settings in both config files so that these are the same:

 

define('DB_SERVER', '');

define('DB_SERVER_USERNAME', '');

define('DB_SERVER_PASSWORD', '');

define('DB_DATABASE', '');

Link to comment
Share on other sites

Jeff -

 

Thanks for all of your help. Your script confirmed that my mods were correct. We did connect to the database. - but via httpd only - not via https!

 

But then I finally got a support reply from the host:

 

"Hello Alan,

 

When you are editing these files, are you editing them through ftp.sonic.net or shell.sonic.net? If so, the files on the SSL server are not being changed. The SSL server is on ssl.sonic.net, completely separate from the other files in the non-SSL area. I hope that helps. Please let us know!"

 

IT WAS THE SSL files. They were NOT symlinked to the visible files. I had to ftp to ssl.hostname.com. It was not sufficient to update the main scripts. THERE WERE SSL VERSIONS ON A DIFFERENT SERVER!!!!

 

I logged in, uploaded my updated configure.php files and Voila! Fixed the problem. The shopping cart is up and running again. I am thrilled.

 

On the other hand, I just wish that the darned ISP had responded to me sooner with this information. It was like pulling teeth to get a meaningful answer from them. It wasn't until I submitted the results of your script test ans specifically asked about the ssl connection and alternate files that they told me about the ssl.hostname login. I didn't even know I COULD log in to ssl.hostname.com...

 

Ah, lessons learned. At least now I've learned to debug OSC and have finally gained some experience editing php code. I've been doing cgi and database stuff for ten years, but, believe it or not, this is my first experience with php....

 

Thanks again for your help. That test script did the trick. At least it convinced the support guy that I was not a bumbling idiot....

 

:D :D :D :D :D :D

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...