Please Help! -- Can not connect to database!!

Please Help! -- Can not connect to database!!

by Omar Esquivel -
Number of replies: 25
Hi,

I just installed the latest release of moodle. After I placed the files in the appropriate directory, I created the moodle database and user, when I run the installing page  (install.php) and I get to the step where I have to configure the DB, I get this error..

"We could not connect to the database you specified. Please check your database settings"

My system config is the following...
Fedora Core 3
MySQL 3.23.58
Apache Server 2

I've read similar postings with this problem in the forum but the solutions given haven't fixed it. Please , I'd really appreciate some help here as I don't know what else to do.
Where do I begin checking for the problem???
Thanx in advance.
Average of ratings: -
In reply to Omar Esquivel

Re: Please Help! -- Can not connect to database!!

by Bryan Williams -

Omar,

When asked to give a database name, user name and password, did you add a prefix to the database name and user for the server.

bigmetal_moodle
bigmetal_omar
abc123

In reply to Bryan Williams

Re: Please Help! -- Can not connect to database!!

by Omar Esquivel -
Hi Bryan,

I appreciate your quick reply.

Ok.. in the database configuration page, this is what I'm typing as input:

Type: mysql
Host Server: localhost
Database: moodle  <--- I created this database on mysql from the documentation provided in the site
User: moodleuser
Password: *********
Prefix: mdl_

This is the way I'm filling up the the information, then when I try to continue, I get the error that I can't connect to the database.

Once again, I thank you for any ideas you might provide.


In reply to Omar Esquivel

Re: Please Help! -- Can not connect to database!!

by Tony Hursh -
Did you create the database with a control panel or from a Unix command line? If from the command line, be sure that you executed:

mysqladmin -p reload
In reply to Omar Esquivel

Re: Please Help! -- Can not connect to database!!

by Bryan Williams -
What is the name of your server?
In reply to Bryan Williams

Re: Please Help! -- Can not connect to database!!

by Omar Esquivel -

I created the database from a command line. I just typed mysqladmin -p reload but I still get the error.

My server name is "fedora"

In reply to Omar Esquivel

Re: Please Help! -- Can not connect to database!!

by Bryan Williams -

What happens when you enter:
Host Server: localhost
Database: fedora_moodle
User: fedora_moodleuser (assuming you created this user name in db)
Password: ********* (assuming you created this password in db)

If you did not create a user name and password in the db when you created it, try:
User: root
Password (leave blank)

In reply to Bryan Williams

Re: Please Help! -- Can not connect to database!!

by Omar Esquivel -
Hi Bryan,

I placed the prefix of my server's name and used root as my user and it worked. I'm right now at the next configuration screen.

Thanx a lot! ... you don't know how much I appreciate your help with this problem.

Thanx again!
In reply to Omar Esquivel

Re: Please Help! -- Can not connect to database!!

by magda piasecka -

There are a lot of posts here about installation problems, but this is the only one similar to the one I'm getting.

A local copy of moodle works on my computer (used easyphp package), but when I uploaded a fresh copy of moodle to the internet, I get the error: "We could not connect to the database you specified. Please check your database settings"

The website is hosted by yahoo.

In reply to magda piasecka

Re: Please Help! -- Can not connect to database!!

by Brian Donohue-Lynch -

I ran into this same message just yesterday, and was sure that "localhost" was the problem;  I was lucky though, since I had one instance of moodle that worked, and I found that in the config file my Host Server was called something I hadn't recalled (and I was not sure where I originally got this from):  mysqldb

I just visited the webhost management interface for my website, and there is actually a tool there for managing the MySQL databases I have set up.  There I found the info for my databases, including the MySQL host name: this is the host that the MySQL server is given when it is set up. Your host provider should be able to be more specific on this, either through some automatic interface, or through some manual investigation.

Brian

In reply to Brian Donohue-Lynch

Re: Please Help! -- Can not connect to database!!

by magda piasecka -

Thanks for your suggestions Briansmile

I'm using PHPMyAdmin version 2.5.0 to manage my databases.
(It's a tool written in PHP intended to handle the administration of MySQL over the Web.)

When I log into it, the top line reads:

In reply to magda piasecka

Re: Please Help! -- Can not connect to database!!

by Bryan Williams -
Can you try flydragontech (leave out .com) for your database property. You can also ping this database server and enter the IP address in Moodles properties during set up. So, your properties might look something like:

Type

 mysql

Host Server

 localhost

Database

 flydragontech_moodledb

User

 flydragontech_flydragon960

Password

 *********

Tables prefix

 _mdl
 
In reply to Bryan Williams

Re: Please Help! -- Can not connect to database!!

by Paolo Conti -

I have the same problem. My installation is:

MySQL 4.017

PHP 4.3.4

Apache 1.3.29

I have already 2 installations of Moodle 1.3.1 without any problem.

Now I'm trying to install Moodle 1.4.2 within the same environment.

I've created a new database and a new user with a new password and I've modified the config.php for this new installation but I recive the message:

"Error: Database connection failed.

It is possible that the database is overloaded or otherwise not running properly.

The site administrator should also check that the database details have been correctly specified in config.php"

I have already tryed to use the autoconfig procedure (not manual like in the old version) but with the same problem.

What can I do ?

Thank you for yours suggestions.

Bye, Paolo.

In reply to Bryan Williams

Re: Please Help! -- Can not connect to database!!

by kate earl -

I also have this same issue.

My server name has an underscore in it which means that if I put it infront of the database name it would read:

Database: EARL_K_moodle

Could this be my problem?

In reply to kate earl

Re: Please Help! -- Can not connect to database!!

by Andrew McMillan -
This is quite likely to contribute to your problem since he underscore character is not allowed as part of a domain name.

Can you refer to it by a valid domain name, or by an IP address instead?  If it is on the same server then "localhost" or "127.0.0.1" should work better.

In reply to Andrew McMillan

Re: Please Help! -- Can not connect to database!!

by kate earl -

I only tried to put the system name (EARL_K) in desperation.

I can run the installation script using http://localhost/moodle/install.php

I can connect to the database using  Database: moodle    User: moodle   After which MySQL Administrator says along the top  moodle@localhost:3306

I had a look in my Apache config file and set the "ServerName" to be "earl"

however the install.php still comes up with the ''could not connect'' message with both of the following combinations

Type: mysql

Host Server: localhost

Database: localhost_moodle

User: localhost_moodle

Password: *********

Tables prefix: mdl_

Type: mysql

Host Server: localhost

Database: earl_moodle

User: earl_moodle

Password: *********

Tables prefix: mdl_

 

Do I need to set the server name elsewhere than httpd.conf in Apache?

Many thanks for the prompt reply,

Kate

In reply to kate earl

Re: Please Help! -- Can not connect to database!!

by Penny Leach -
try putting
dbname moodle
dbuser moodle

without the localhost_ or earl_ parts.
In reply to Penny Leach

Re: Please Help! -- Can not connect to database!!

by kate earl -

still no joy.

having database: moodle   user: moodle doesn't seem to work either.

Thanks for the suggestion

In reply to kate earl

Re: Please Help! -- Can not connect to database!!

by David Wilkinson -

Kate,

what are your versions of software:

Webserver
Database
OS

Are you installing on your own machine or an ISP or a combo?

David

In reply to David Wilkinson

Re: Please Help! -- Can not connect to database!!

by kate earl -

I unistalled EVERYTHING and started from scratch.

This time at the install.php screen that is causing us all so much trouble I entered the following:

Host Server: localhost

Database: moodle

User: root

Password: <blank>

AND IT WORKED THIS TIME!!!!

(no idea what I had done wrong the first time)

Thank-you to everyone - your prompt replies and suggestions have been wonderful.

In reply to kate earl

Re: Please Help! -- Can not connect to database!!

by Brian Donohue-Lynch -

Did you try:

Host Server:  earl

Database:  moodle

User:   moodle

Brian

In reply to kate earl

Re: Please Help! -- Can not connect to database!!

by David Wilkinson -

Yes,

Underscores are a problem.

Basically, I would stick to a database name that complies with valid DNS (Domain Name Server) entries.  This way your DNS can locate your Database Server properly.

cliipped from: http://www.aboutdomains.com/News/FAQ.htm

What are the valid characters for a domain name and how long can it be?
The only valid characters for a domain name are letters, numbers and a hyphen. Special characters like the underscore "_" or "&" are NOT permitted. Domain names cannot contain spaces or begin or end with a hyphen, "-".

A domain name can be up to 63 characters long including the 4 characters used to identify the Top Level Domain (.NET, .COM, .ORG, or .EDU).

Examples:

DomainMart.com is a valid domain name (it consists of only 13 characters).

http://www.DomainMart.com is not a domain name; it is a uniform resource locator (URL) used by Web browsers to find documents and resources.

www.accounting.DomainMart.com is not a domain name; "accounting" is a third-level domain name.

Regards,
David

In reply to Bryan Williams

Re: Please Help! -- Can not connect to database!!

by magda piasecka -

I'm just wondering why so many people are having trouble with this "install.php" thing.

In reply to magda piasecka

Re: Please Help! -- Can not connect to database!!

by David Wilkinson -

Madge,
I have moodle (Apache,MySQL, PHP) setup on several different ISP servers. 

Here is an example of my config.php:
The names have been changed to protect the innocent:

host name: www.myserver.com
databasename: myserver
database login id: david
database password: something

$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'myserver.com';
$CFG->dbname    = 'myserver';
$CFG->dbuser    = 'david';
$CFG->dbpass    = 'something';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';

Try this:

$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'flydragontech.com';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'flydragontech960';
$CFG->dbpass    = 'your password goes here';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';

If this does not work, look in the apache webserver error_log (if you can access that file, usually located somewhere under /usr/local/apache/logs or or something close to that), and post the error message in this forum.  Possibly Yahoo placed your database on a different server.

btw - ping is done like this:
open a dos command window
at the dos prompt type: ping flydragontech.com
the resultant output contains an IP address can be put as an value in the dbhost variable as another option to point to the server like this:

$CFG->dbhost    = '66.218.79.149';

which happens to be the IP of your server: flydragontech.com

NOTE: Sometimes, when you create your database, your ISP places the MySQL Server on another server - something like: sql18.yahoo.com or some other identifier.  Look for this when you login using PHPMyAdmin.  When you login, what is the server name.  That is the name you put into the moodle config file.

One Last Thought: Are you sure you are typing the password correctly into the config file?  I believe it is case sensitive...

Regards,
David
www.thewilk.com
If this doesn't work, maybe a quick phone conversation will work better.

In reply to David Wilkinson

Re: Please Help! -- Can not connect to database!!

by magda piasecka -

Thanks a lot for your help David!

In reply to magda piasecka

Resolved Host Serve name

by Ethan Pang -

I had the same problem but realised that the problem is that the example given by moodle was not very helpful for my case.

My db host server is mysql.powweb.com. But to get moodle to accept the host server name in the installation, I used only "mysql".

"Localhost" should only be used if you are using your own computer as the testbed.

Cheers,
Ethan