News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Error -- " Cannot connect to database server with given data!" FIXED

Started by punt, April 08, 2004, 12:47:26 PM

Previous topic - Next topic

punt

Howdy all,

I'm having a frustrating problem, and I'm wondering if anyone can lend a hand.

After filling out the SMF Installer page (things such as MySQL Servername, MySQL Database name, etc), I get the following error:

Cannot connect to database server with given data!

Please check the information you provided, and then try again.


I followed [Unknown]'s Guide to Installing PHP and MySQL (found here [nofollow] for those that haven't seen it. Great guide :) ) and all the testing for php and MySQL indicated that both those programs are functioning correctly.

The error message give doesn't expand on what the problem might be, so I'm not sure if it's the User/Password that's having a problem, or maybe the choice of database name. I did create a MySQL user to use only for SMF, and I am able to login in from the console using that user.

Here's some spec's:
Apache 2.0.40
MySql  4.0.18-standard
PHP Version 4.3.5

Any thoughts about what's going on? Any more info needed?

Any help at all would be greatly appreciated.

thanks :)

-punt

Chris Cromer

Well that error means that either the user or password is wrong. Or that user doesn't have access to the  SMF database.
Chris Cromer

"I was here, here I was, was I here, sure I was" - The little voice in my head.

[Unknown]


punt

I had created a mysql user specifically for use with SMF. At first, I just granted all privileges to smf.* . Then I tried granting ALL privileges on *.*.

Finally, I tried using root (with the root password) to complete the install page, and I'm getting the same error message.

It would seem I have something else screwed up, but can't figure out what. I have logged in as my SMF user to mysql and accessed the self-created smf database through the console with no problems. I've tried letting the installer create the SMF database, and have tried it with the db already created.

Root has it's password set, so I used that. For kicks, I tried logging in without the root password, but, as expected, I get the same error...

Any more ideas?

Thanks for the quick replies as well :)

-punt

[Unknown]

Hmm... does phpMyAdmin work at all?

What if you do this:

Start -> Run -> cmd

cd "C:\where you installed MySQL\bin"
mysql -uUSERNAME -pPASSWORD

This is probably the easiest and quickest way of trying it.  Once you get it open, try the following:
SHOW DATABASES;

And then you can type "exit" to quit back to the command prompt.

-[Unknown]

punt

Quote from: [Unknown] on April 08, 2004, 02:22:51 PM
Hmm... does phpMyAdmin work at all?

I don't have phpMyAdmin installed on this particular box...

Quote
What if you do this:

Start -> Run -> cmd

cd "C:\where you installed MySQL\bin"
mysql -uUSERNAME -pPASSWORD

This is probably the easiest and quickest way of trying it.  Once you get it open, try the following:
SHOW DATABASES;

And then you can type "exit" to quit back to the command prompt.

-[Unknown]

I don't have any problems getting to mysql from the console (I'm using a linux box btw...). I can see the SMF database I've created after logging in with the smf account I created:

[x@x]# mysql -u smf -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 21 to server version: 4.0.18-standard

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> show databases;
+----------+
| Database |
+----------+
| bugs     |
| database |
| mysql    |
| smf      |
| test     |
+----------+
5 rows in set (0.00 sec)

mysql>


As far as I can tell, everything MySQL wise is working fine. It's just when I try to run the install.php through my browser is where it all hangs up....

Thanks again for all the help. This is getting very frustrating ::)

[Unknown]

And you're using localhost/smf/that password/smf for server/user/password/database?

-[Unknown]

punt


[Unknown]

Do you have an external URL?  If so, can you maybe let me give it a shot?

-[Unknown]

punt

Unfortunatly it's an inhouse server behind the firewall. No outside visitors allowed :(

[Unknown]

Open install.php, and look for the following:

@mysql_connect

Change it to:

mysql_connect

And then try again, it will give you a more detailed error message.

-[Unknown]

punt

I tried as suggest, and didn't receive any more detail than previously.

I found it in this line:
// Attempt a connection.
        $db_connection = @mysql_connect($db_server, $db_user, $db_passwd);


Is that the right one? I searched, and it appeared to be the only one.

Also, as a side note, I noticed that in the install.php, I have a line that reads:
define('SMF_MYSQL_VERSION', '3.23.4');

As noted before, I have MySQL 4.0.18. Is this just a statement defining the minimum required version of MySQL?




[Unknown]

Yes, I use MySQL 4.0.18 for my own personal testing as well.

No other detail at all?  What if you find @mysql_select_db and take off the @?

-[Unknown]

punt

Quote from: [Unknown] on April 08, 2004, 04:36:49 PM

No other detail at all?  What if you find @mysql_select_db and take off the @?


Hrm...ok, I went to search for @mysql_select_db and there's nothing in the install.php file.

Could this be part of the problem?

[Unknown]

Sorry, I guess it doesn't even have an @.

Try replacing this: (@ or no @.)

$db_connection = @mysql_connect($db_server, $db_user, $db_passwd);

With:

$db_connection = mysql_connect($db_server, $db_user, $db_passwd);
echo mysql_error();print_r($db_connection);

-[Unknown]

punt

Thanks for all your patience with this.

I did as suggested and along with the previous error, I now get

"Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"

Which comes right before the " Cannot connect to database server with given data!

Please check the information you provided, and then try again."

It's odd 'cause I _can_ connect using the same password and user through the console.

I'm baffled. Hope you're not :)

Thanks again,

-punt

[Unknown]

Sounds like the way you have set up MySQL is not allowing PHP to connect to it...

I'm not expert on Linux, sorry.

-[Unknown]

punt

I couldn't ask for more help than you gave me already, so thanks :)

Though just as a side note, I did create a mysql_connect.php file as suggested in your tutorial with the following:

<?php
 mysql_connect
('localhost''smf''password');
 
mysql_select_db('test');

 echo 
'Unless you see any error messages, everything should be fine.';
?>



Loaded it on the server, and it connected fine, with just the "Unless you see any error messages, everything should be fine" line. So it would seem that linux is working fine with MySQL connections through PHP.

But again, thanks for all the help. Any Linux Guru's out there that might know what's going on??

-punt

punt

Thanks to all who helped.

I found the answer to my problem. Apparently my install of mysql had its local pesudo filesystem socket in an unexpected location. I symlinked the file with:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
...and all was good with the world.

Thanks a ton for the help!!!  :D

Advertisement: