nikes Posted February 24, 2009 Share Posted February 24, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/ Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770361 Share on other sites More sharing options...
nikes Posted February 24, 2009 Author Share Posted February 24, 2009 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"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770365 Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 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()); Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770368 Share on other sites More sharing options...
nikes Posted February 24, 2009 Author Share Posted February 24, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770376 Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770377 Share on other sites More sharing options...
nikes Posted February 24, 2009 Author Share Posted February 24, 2009 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) Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770386 Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 is your mysql server running? on the command line: ps -ef | grep mysql Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770421 Share on other sites More sharing options...
nikes Posted February 24, 2009 Author Share Posted February 24, 2009 is your mysql server running? on the command line: ps -ef | grep mysql yes it's running Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770431 Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770457 Share on other sites More sharing options...
nikes Posted February 24, 2009 Author Share Posted February 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770462 Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 my guess is it's a permission issue. are there any errors in your mysql error log? and what are the permissions on the sock file? Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770466 Share on other sites More sharing options...
nikes Posted February 24, 2009 Author Share Posted February 24, 2009 my guess is it's a permission issue. are there any errors in your mysql error log? and what are the permissions on the sock file? in the error log it says "log file not found" and how do you find/edit the permissions on the sock file? Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770473 Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 ok...that should be the problem...do you know where your my.cnf file is? it is probably in the output from this: ps -ef | grep mysql if not, what OS are you running? Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770489 Share on other sites More sharing options...
nikes Posted February 24, 2009 Author Share Posted February 24, 2009 ok...that should be the problem...do you know where your my.cnf file is? it is probably in the output from this: ps -ef | grep mysql if not, what OS are you running? Yes, i see the my.cnf file in the directory /etc/mysql/my.cnf Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770506 Share on other sites More sharing options...
fenway Posted February 25, 2009 Share Posted February 25, 2009 The socket issue is covered in a sticky on the installation/config child board. Quote Link to comment https://forums.phpfreaks.com/topic/146735-cannot-connect-to-server/#findComment-770824 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.