Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Post by Ada » Sun, 19 Jan 2003 11:31:33



I have a fresh installation of OpenBSD 3.2.  I have not made any
alterations to the base installation.  I enabled Apache via rc.conf
and tested (I also enabled server-status & server-info in httpd.conf).

I installed PHP4 from the packages tree at 3.2/Packages.  I configured
according to the instructions at webmonkey and tested with phpinfo().
I integrated with Apache and tested with the sample php3 script shown
below:

<html>
<body>
<?php
$myvar = "Hello Adam";
echo $myvar;
?>
</body>
</html>

which worked fine. (Returned "Hello Adam")

I then installed mysql from the package currently in 3.2/Packages with
its supporting packages (p5-DBD-1.30, mysql-client-3.23.54,
p5-DBD-Mssql-Mysql-1.22.19, libiconv-1.8, gettext-0.10.40 and
recode-3.6).  I enabled MySQL to start at reboot using the
instructions at http://www.hostbaby.com/misc/mysql-openbsd.html.
After a reboot, mysql starts on port 3306 w/a PID of 8643.  I set the
password, created a test database and verified the functionality of
the base databases.

I added the php4-mysql-4.2.3 package to enable integration with MySql
and verified that phpinfo() returns MySQL integration successfully,
which it does.

I prepared the following script in /var/www/htdocs (named test2.php3):
<html>
<body>
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT * FROM employees",$db);
printf("First Name: %s<br>\n", mysql_result($result,0,"first"));
?>
</body>
</html>

When I open my browser to http://target_Svr/test2.php3, I get the
following

Warning: Can't connect to local MySQL server through socket
'/var/run/mysql/mysql.sock' (2) in /htdocs/test2.php3 on line 7

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/run/mysql/mysql.sock' (2) in /htdocs/test2.php3
on line 7

Warning: mysql_select_db(): supplied argument is not a valid
MySQL-Link resource in /htdocs/test2.php3 on line 9

Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in /htdocs/test2.php3 on line 11

Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in /htdocs/test2.php3 on line 13
First Name:

So, I rolled over to /var/run/mysql and noticed that mysql.sock did
exist with filesize 0.

I have been searching and working on this for over a week, any help
would be greatly appreciated.  Top it off, its for a non-profit org
that I decided to help out.. so its a good cause.

 
 
 

Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Post by Sean » Sun, 19 Jan 2003 12:08:44



> I have a fresh installation of OpenBSD 3.2.  I have not made any
> alterations to the base installation.  I enabled Apache via rc.conf
> and tested (I also enabled server-status & server-info in httpd.conf).

> I installed PHP4 from the packages tree at 3.2/Packages.  I configured
> according to the instructions at webmonkey and tested with phpinfo().
> I integrated with Apache and tested with the sample php3 script shown
> below:

> <html>
> <body>
> <?php
> $myvar = "Hello Adam";
> echo $myvar;
> ?>
> </body>
> </html>

> which worked fine. (Returned "Hello Adam")

> I then installed mysql from the package currently in 3.2/Packages with
> its supporting packages (p5-DBD-1.30, mysql-client-3.23.54,
> p5-DBD-Mssql-Mysql-1.22.19, libiconv-1.8, gettext-0.10.40 and
> recode-3.6).  I enabled MySQL to start at reboot using the
> instructions at http://www.hostbaby.com/misc/mysql-openbsd.html.
> After a reboot, mysql starts on port 3306 w/a PID of 8643.  I set the
> password, created a test database and verified the functionality of
> the base databases.

> I added the php4-mysql-4.2.3 package to enable integration with MySql
> and verified that phpinfo() returns MySQL integration successfully,
> which it does.

> I prepared the following script in /var/www/htdocs (named test2.php3):
> <html>
> <body>
> <?php
> $db = mysql_connect("localhost", "root");
> mysql_select_db("mydb",$db);
> $result = mysql_query("SELECT * FROM employees",$db);
> printf("First Name: %s<br>\n", mysql_result($result,0,"first"));
> ?>
> </body>
> </html>

You say above that you set the mysql password.  I assume you mean you
set the root password.  If that's correct, you should use the root
password in your mysql_connect function like mysql_connect("HOST",
"USER", "PASSWORD");

- Show quoted text -

Quote:> When I open my browser to http://target_Svr/test2.php3, I get the
> following

> Warning: Can't connect to local MySQL server through socket
> '/var/run/mysql/mysql.sock' (2) in /htdocs/test2.php3 on line 7

> Warning: MySQL Connection Failed: Can't connect to local MySQL server
> through socket '/var/run/mysql/mysql.sock' (2) in /htdocs/test2.php3
> on line 7

> Warning: mysql_select_db(): supplied argument is not a valid
> MySQL-Link resource in /htdocs/test2.php3 on line 9

> Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> resource in /htdocs/test2.php3 on line 11

> Warning: mysql_result(): supplied argument is not a valid MySQL result
> resource in /htdocs/test2.php3 on line 13
> First Name:

> So, I rolled over to /var/run/mysql and noticed that mysql.sock did
> exist with filesize 0.

> I have been searching and working on this for over a week, any help
> would be greatly appreciated.  Top it off, its for a non-profit org
> that I decided to help out.. so its a good cause.

You might want to check the permissions of the socket, making sure
everyone has access to it.

 
 
 

Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Post by Hans Zimmerma » Sun, 19 Jan 2003 18:08:08


<snip>

Quote:

> Warning: Can't connect to local MySQL server through socket
> '/var/run/mysql/mysql.sock' (2) in /htdocs/test2.php3 on line 7

<snip>

Quote:

> So, I rolled over to /var/run/mysql and noticed that mysql.sock did
> exist with filesize 0.

I hope you can see where the error is. Chech following doc for my.cnf
and the location of a mysql socket:
http://www.mysql.com/doc/en/Option_files.html
Or maybe just make the /var/run/mysql directory (like mentioned on the
website you followed (http://www.hostbaby.com/misc/mysql-openbsd.html).
mkdir /var/mysql
chown mysql:mysql /var/mysql

Good luck,

Hans

 
 
 

Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Post by Ada » Sun, 19 Jan 2003 22:51:52




> > I have a fresh installation of OpenBSD 3.2.  I have not made any
> > alterations to the base installation.  I enabled Apache via rc.conf
> > and tested (I also enabled server-status & server-info in httpd.conf).

> > I installed PHP4 from the packages tree at 3.2/Packages.  I configured
> > according to the instructions at webmonkey and tested with phpinfo().
> > I integrated with Apache and tested with the sample php3 script shown
> > below:

> > <html>
> > <body>
> > <?php
> > $myvar = "Hello Adam";
> > echo $myvar;
> > ?>
> > </body>
> > </html>

> > which worked fine. (Returned "Hello Adam")

> > I then installed mysql from the package currently in 3.2/Packages with
> > its supporting packages (p5-DBD-1.30, mysql-client-3.23.54,
> > p5-DBD-Mssql-Mysql-1.22.19, libiconv-1.8, gettext-0.10.40 and
> > recode-3.6).  I enabled MySQL to start at reboot using the
> > instructions at http://www.hostbaby.com/misc/mysql-openbsd.html.
> > After a reboot, mysql starts on port 3306 w/a PID of 8643.  I set the
> > password, created a test database and verified the functionality of
> > the base databases.

> > I added the php4-mysql-4.2.3 package to enable integration with MySql
> > and verified that phpinfo() returns MySQL integration successfully,
> > which it does.

> > I prepared the following script in /var/www/htdocs (named test2.php3):
> > <html>
> > <body>
> > <?php
> > $db = mysql_connect("localhost", "root");
> > mysql_select_db("mydb",$db);
> > $result = mysql_query("SELECT * FROM employees",$db);
> > printf("First Name: %s<br>\n", mysql_result($result,0,"first"));
> > ?>
> > </body>
> > </html>

> You say above that you set the mysql password.  I assume you mean you
> set the root password.  If that's correct, you should use the root
> password in your mysql_connect function like mysql_connect("HOST",
> "USER", "PASSWORD");

> > When I open my browser to http://target_Svr/test2.php3, I get the
> > following

> > Warning: Can't connect to local MySQL server through socket
> > '/var/run/mysql/mysql.sock' (2) in /htdocs/test2.php3 on line 7

> > Warning: MySQL Connection Failed: Can't connect to local MySQL server
> > through socket '/var/run/mysql/mysql.sock' (2) in /htdocs/test2.php3
> > on line 7

> > Warning: mysql_select_db(): supplied argument is not a valid
> > MySQL-Link resource in /htdocs/test2.php3 on line 9

> > Warning: mysql_query(): supplied argument is not a valid MySQL-Link
> > resource in /htdocs/test2.php3 on line 11

> > Warning: mysql_result(): supplied argument is not a valid MySQL result
> > resource in /htdocs/test2.php3 on line 13
> > First Name:

> > So, I rolled over to /var/run/mysql and noticed that mysql.sock did
> > exist with filesize 0.

> > I have been searching and working on this for over a week, any help
> > would be greatly appreciated.  Top it off, its for a non-profit org
> > that I decided to help out.. so its a good cause.

> You might want to check the permissions of the socket, making sure
> everyone has access to it.

Thanks for the quick response.  The sock file has all permisions
applied to it and I tried using the password as part of my connect
statement - no luck.  Any other ideas?
 
 
 

Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Post by Peter Str?mber » Tue, 21 Jan 2003 20:59:43



Quote:> I have a fresh installation of OpenBSD 3.2.  I have not made any
> alterations to the base installation.  I enabled Apache via rc.conf
> and tested (I also enabled server-status & server-info in httpd.conf).
> ...
> I prepared the following script in /var/www/htdocs (named test2.php3):
> <html>
> <body>
> <?php
> $db = mysql_connect("localhost", "root");
> ...

Apache is chroot-ed by default in 3.2, use mysql_connect("127.0.0.1", ...)
to connect thru the network rather than the unix domain socket.

--
Peter Str?mberg
ISCCIV02  <http://www.iscc.nu/>

 
 
 

Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Post by Ada » Wed, 22 Jan 2003 12:56:55





> > I have a fresh installation of OpenBSD 3.2.  I have not made any
> > alterations to the base installation.  I enabled Apache via rc.conf
> > and tested (I also enabled server-status & server-info in httpd.conf).
> > ...
> > I prepared the following script in /var/www/htdocs (named test2.php3):
> > <html>
> > <body>
> > <?php
> > $db = mysql_connect("localhost", "root");
> > ...

> Apache is chroot-ed by default in 3.2, use mysql_connect("127.0.0.1", ...)
> to connect thru the network rather than the unix domain socket.

I added changed to 127.0.0.1 and got the message shown below, but with
localhost instead of trinity.  I changed to the real IP and got the
message below.  Odd thing though, I cannot find the my.cnf referenced
above.  Any ideas?

Warning: Host 'trinity.hansen.com' is not allowed to connect to this
MySQL server in /htdocs/test2.php3 on line 7

Warning: MySQL Connection Failed: Host 'trinity.hansen.com' is not
allowed to connect to this MySQL server in /htdocs/test2.php3 on line
7

Warning: mysql_select_db(): supplied argument is not a valid
MySQL-Link resource in /htdocs/test2.php3 on line 9

Warning: mysql_query(): supplied argument is not a valid MySQL-Link
resource in /htdocs/test2.php3 on line 11

Warning: mysql_result(): supplied argument is not a valid MySQL result
resource in /htdocs/test2.php3 on line 13
First Name:

 
 
 

Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Post by Peter Str?mber » Wed, 22 Jan 2003 19:33:49








>>> I have a fresh installation of OpenBSD 3.2.  I have not made any
>>> alterations to the base installation.  I enabled Apache via rc.conf
>>> and tested (I also enabled server-status & server-info in
>>> httpd.conf). ...
>>> I prepared the following script in /var/www/htdocs (named
>>> test2.php3): <html> <body> <?php $db = mysql_connect("localhost",
>>> "root"); ...

>> Apache is chroot-ed by default in 3.2, use mysql_connect("127.0.0.1",
>> ...) to connect thru the network rather than the unix domain socket.

> I added changed to 127.0.0.1 and got the message shown below, but with
> localhost instead of trinity.  I changed to the real IP and got the
> message below.  Odd thing though, I cannot find the my.cnf referenced
> above.  Any ideas?

> Warning: Host 'trinity.hansen.com' is not allowed to connect to this
> MySQL server in /htdocs/test2.php3 on line 7

> Warning: MySQL Connection Failed: Host 'trinity.hansen.com' is not
> allowed to connect to this MySQL server in /htdocs/test2.php3 on line
> 7

You have to give that user permission to connect from the network
http://www.mysql.com/doc/en/MySQL_Database_Administration.html

--
Peter Str?mberg
ISCCIV02  <http://www.iscc.nu/>

 
 
 

Apache / PHP4 / MySql Problem - Can't connect to local MySQL server through socket '/var/run/mysql/mysql.sock'

Post by Kovacs Rober » Sun, 02 Feb 2003 20:56:54


i have installed openbsd 3.2 on my old DEC (compaq) dual processor  machine,
but there are some problems....

my system is a (Prioris XL5120DP):

Dual Processor (two Intel Pentium Processors 100MHz)
50MB RAM
1 SCSI CDROM
1 EIDE HDD (2gig)

    its an old machine, and perhaps thats the problem, could it be?????

i installed everything but at the end of the installation, the machine needs
a lot of time while the screen shows "Remaking all the devices"
okkie... no problem.... and after 8min.... the machine shows the normal "End
Installation Message..." like...

"You've installed OpenBSD 3.2 successfully, type Halt to restart....." and
so... on........

i restart my machine, but the bootloader show an error message like:

"boot.conf" "error" "input/output error"
and that the machine can't load the kernel.... and so... on....
the machine does not boot....

the partitons are....
0 not in use
1 not in use
2 not in use
3 used and marked as bootable

on the HDD there is no boot.conf in the /etc directory..... is this the
problem????

i have no idea... i am a newbie in openbsd.
thanks a lot,

 
 
 

1. Can't connect to local MySQL server through socket '/tmp/mysql.sock'

I'm trying to use DBI for Perl to connect to remote MySQL database and
getting following:
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Any ideas of how to get thru that?  I'm sure it's UNIX networking
problem.

Sent via Deja.com http://www.deja.com/
Before you buy.

2. Redhat 5.2 restore

3. Problems with portmap-4.0

4. PHP/MySQL "mysql.sock" not found ???

5. Xgks gracphics program Help

6. Only user "root" and "mysql" can connect to mysql?

7. Files with funny character names

8. mySQL: where is mysql-server.sh?

9. start mysql database as mysql instead of root

10. mysql with c, cant find declaration of mysql-functions...

11. Mysql and Mysql.pm