Jump to content

"cannot connect to server"


nikes

Recommended Posts

Well, I'm making a social networking site where users can chat with each other,etc..

and I'm using MySQL administrator on Ubuntu(to act as a server) to store registered users

 

The problem is when i try to register for the site, it gives me this error message

 

"cannot connect to server"

 

What does this mean?

 

 

i set up the config file with the $host, $username, $password, and $db_name.......what's wrong?

 

Server information

 

MySQL Version: MySQL 5.0.51a-3ubuntu5.4

Network Name: localhost

 

and the client information:

 

Version: MySQL Client Version 5.0.51

Operating System: Linux 2.6.24-23-generic

 

Please help me!

 

Link to comment
https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/
Share on other sites

please provide the code you are using to connect to the mysql server. also, try echoing the value of mysql_error() where it is failing

 

<?php

 

$host=""; // Host name

$username=""; // Mysql username

$password=""; // Mysql password

$db_name=""; // Database name

 

 

//Connect to server and select database.

mysql_connect("$host", "$username", "$password")or die("cannot connect to server");

mysql_select_db("$db_name")or die("cannot select DB");

 

?>

change this:

mysql_connect("$host", "$username", "$password")or die("cannot connect to server");

to

mysql_connect($host, $username, $password)or die("cannot connect to server: ".mysql_error());

 

 

my web hosting provider website is down...i will post the output when the site is back up. sorry...

change this:

mysql_connect("$host", "$username", "$password")or die("cannot connect to server");

to

mysql_connect($host, $username, $password)or die("cannot connect to server: ".mysql_error());

 

my web hosting provider website is down...i will post the output when the site is back up. sorry...

 

sounds like it's time for a new web hosting provider

change this:

mysql_connect("$host", "$username", "$password")or die("cannot connect to server");

to

mysql_connect($host, $username, $password)or die("cannot connect to server: ".mysql_error());

 

my web hosting provider website is down...i will post the output when the site is back up. sorry...

 

sounds like it's time for a new web hosting provider

 

lol ok it's back up:

 

here is the output:

 

cannot connect to server: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

and you can connect to it from the command line? if so, what socket is that using?

 

connect with:

mysql -u root -p

then from the mysql prompt run:

status

 

Yes, i can connect from the command line. It shows every thing about the mysql.

 

The socket that it's using is:

 

UNIX socket: /var/run/mysqld/mysqld.sock

 

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.