|
Hi, I've searched and searched and am a little numb at this point. I haven't been able to find a solution to an error I am receiving when attempting to connect to a remote mysql server with a php script. Here is the ERROR: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) Background: Two servers running FreeBSD v6.0 STABLE Server1: apache-2.2.0_2, php5-5.1.1, php5-mysql-5.1.1, mysql-client-5.0.16 Server2: mysql-server-5.0.16, mysql-client-5.0.16 What I've tried: 1. Connecting via command line works fine: me@server1% mysql -h server2 -p -u me Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 64 to server version: 5.0.16 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>quit; 2. Connecting via php (error above): $host='server2'; $user='me'; $passwd='mypassword'; $cn = mysql_connect("$host", "$user", "$passwd"); if(!$cn) { die(mysql_error()); } I am assuming the reason the /tmp/mysql.sock file doesn't exist on server1 is because mysql is not running on this server. Thanks in advanced, Greg _______________________________________________ [hidden email] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-database To unsubscribe, send any mail to "[hidden email]" |
|
S. Greg Cuff wrote:
> Here is the ERROR: > Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) > > Background: > > Two servers running FreeBSD v6.0 STABLE > > Server1: apache-2.2.0_2, php5-5.1.1, php5-mysql-5.1.1, > mysql-client-5.0.16 > Server2: mysql-server-5.0.16, mysql-client-5.0.16 > > What I've tried: > > 1. Connecting via command line works fine: > me@server1% mysql -h server2 -p -u me > Enter password: > Reading table information for completion of table and column names > You can turn off this feature to get a quicker startup with -A > > Welcome to the MySQL monitor. Commands end with ; or \g. > Your MySQL connection id is 64 to server version: 5.0.16 > > Type 'help;' or '\h' for help. Type '\c' to clear the buffer. > > mysql>quit; > > 2. Connecting via php (error above): > $host='server2'; > $user='me'; > $passwd='mypassword'; > > $cn = mysql_connect("$host", "$user", "$passwd"); > if(!$cn) > { > die(mysql_error()); > } > > I am assuming the reason the /tmp/mysql.sock file doesn't exist on server1 > is because mysql is not running on this server. > > Thanks in advanced, > > Greg Try to connect with IP address instead of hostname. AFAIK /tmp/mysql.sock is used for localhost connections only. Miroslav Lachman _______________________________________________ [hidden email] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-database To unsubscribe, send any mail to "[hidden email]" |
|
I received the same message using $host = '192.168.1.2'; or $host = '192.168.1.2:3306'; It was my understanding that only if the host is null or the string is 'localhost' then sockets would be used to connect to the database. This seems such a drastic solution and I'm reluctant to do this but, should I delete any packages and reinstall? If, so what is the best way to go about this? Any preferred order? Thanks, Greg On Mon, 13 Feb 2006, Miroslav Lachman wrote: ...S. Greg Cuff wrote: ... ...> Here is the ERROR: ...> Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) ...> ...> Background: ...> ...> Two servers running FreeBSD v6.0 STABLE ...> ...> Server1: apache-2.2.0_2, php5-5.1.1, php5-mysql-5.1.1, ...> mysql-client-5.0.16 ...> Server2: mysql-server-5.0.16, mysql-client-5.0.16 ...> ...> What I've tried: ...> ...> 1. Connecting via command line works fine: ...> me@server1% mysql -h server2 -p -u me ...> Enter password: ...> Reading table information for completion of table and column names ...> You can turn off this feature to get a quicker startup with -A ...> ...> Welcome to the MySQL monitor. Commands end with ; or \g. ...> Your MySQL connection id is 64 to server version: 5.0.16 ...> ...> Type 'help;' or '\h' for help. Type '\c' to clear the buffer. ...> ...> mysql>quit; ...> ...> 2. Connecting via php (error above): ...> $host='server2'; ...> $user='me'; ...> $passwd='mypassword'; ...> ...> $cn = mysql_connect("$host", "$user", "$passwd"); ...> if(!$cn) ...> { ...> die(mysql_error()); ...> } ...> ...> I am assuming the reason the /tmp/mysql.sock file doesn't exist on server1 ...> is because mysql is not running on this server. ...> ...> Thanks in advanced, ...> ...> Greg ... ... ...Try to connect with IP address instead of hostname. AFAIK .../tmp/mysql.sock is used for localhost connections only. ... ...Miroslav Lachman ... _______________________________________________ [hidden email] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-database To unsubscribe, send any mail to "[hidden email]" |
|
In reply to this post by Miroslav Lachman
One thing to check, don't think it applies to the version you are
using but has caused me a similar problem in the past. Make sure your php compiled mysql client and mysql server are using the same encryption schema on the password. http://dev.mysql.com/doc/refman/5.0/en/old-client.html Another thing is what does the die display? whats the mysql Error? that might help give a bit more information. On 2/13/06, Miroslav Lachman <[hidden email]> wrote: > S. Greg Cuff wrote: > > > Here is the ERROR: > > Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) > > > > Background: > > > > Two servers running FreeBSD v6.0 STABLE > > > > Server1: apache-2.2.0_2, php5-5.1.1, php5-mysql-5.1.1, > > mysql-client-5.0.16 > > Server2: mysql-server-5.0.16, mysql-client-5.0.16 > > > > What I've tried: > > > > 1. Connecting via command line works fine: > > me@server1% mysql -h server2 -p -u me > > Enter password: > > Reading table information for completion of table and column names > > You can turn off this feature to get a quicker startup with -A > > > > Welcome to the MySQL monitor. Commands end with ; or \g. > > Your MySQL connection id is 64 to server version: 5.0.16 > > > > Type 'help;' or '\h' for help. Type '\c' to clear the buffer. > > > > mysql>quit; > > > > 2. Connecting via php (error above): > > $host='server2'; > > $user='me'; > > $passwd='mypassword'; > > > > $cn = mysql_connect("$host", "$user", "$passwd"); > > if(!$cn) > > { > > die(mysql_error()); > > } > > > > I am assuming the reason the /tmp/mysql.sock file doesn't exist on server1 > > is because mysql is not running on this server. > > > > Thanks in advanced, > > > > Greg > > > Try to connect with IP address instead of hostname. AFAIK > /tmp/mysql.sock is used for localhost connections only. > > Miroslav Lachman > _______________________________________________ > [hidden email] mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-database > To unsubscribe, send any mail to "[hidden email]" > -- Justin Bastedo At Gmail Dot Com -------------------------------------------------- http://www.thebastedo.com _______________________________________________ [hidden email] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-database To unsubscribe, send any mail to "[hidden email]" |
| Powered by Nabble | Edit this page |
