From owner-freebsd-database@FreeBSD.ORG Mon Feb 13 09:30:46 2006 Return-Path: X-Original-To: freebsd-database@freebsd.org Delivered-To: freebsd-database@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9289D16A420 for ; Mon, 13 Feb 2006 09:30:46 +0000 (GMT) (envelope-from 000.fbsd@quip.cz) Received: from home.quip.cz (grimm.quip.cz [213.220.192.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2913043D48 for ; Mon, 13 Feb 2006 09:30:45 +0000 (GMT) (envelope-from 000.fbsd@quip.cz) Received: from [192.168.1.2] (qwork.quip.test [192.168.1.2]) by home.quip.cz (Postfix) with ESMTP id E7B1B61F8; Mon, 13 Feb 2006 10:30:43 +0100 (CET) Message-ID: <43F051C3.7090704@quip.cz> Date: Mon, 13 Feb 2006 10:30:43 +0100 From: Miroslav Lachman <000.fbsd@quip.cz> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: cs, cz, en, en-us MIME-Version: 1.0 To: "S. Greg Cuff" References: <20060212213438.O35939-100000@krynn.brundoggy.com> In-Reply-To: <20060212213438.O35939-100000@krynn.brundoggy.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-database@freebsd.org Subject: Re: Error connecting to mysql via php X-BeenThere: freebsd-database@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Database use and development under FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Feb 2006 09:30:46 -0000 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