Page 1 of 1

System_daemon:how to change mysql socket path?

Posted: Wed Feb 24, 2010 3:39 am
by nadirkm
hey everyone...
i was tring to create a php daemon using system_daemon class. As i am in Lampp environment i get the problem that , system_daemon is is connecting to default mysql which i have stopped before starting lampp. i would like to know , how i can change its socket path to /opt/lampp/var... ? where i can make this path change?

thanks in advance.

Re: System_daemon:how to change mysql socket path?

Posted: Wed Feb 24, 2010 9:10 am
by AbraCadaver
In php.ini, change mysql.default_socket or in your script:

Code: Select all

ini_set('mysql.default_socket', '/opt/lampp/var/mysql.sock');
Or when connecting:

Code: Select all

mysql_connect(':/opt/lampp/var/mysql.sock', 'username', 'password');
Or you could link to it in the file system:

Code: Select all

ln -s /opt/lampp/var/mysql.sock /tmp/mysql.sock

Re: System_daemon:how to change mysql socket path?

Posted: Wed Feb 24, 2010 11:36 am
by nadirkm
thanks for the reply.. but i couldn clear my problem. i am sorry , i am a newbie.. pls correct me.. i will post my code here.

Code: Select all

#!/usr/bin/php -q
<?php
    require_once "System/Daemon.php";                 // Include the Class
 
    System_Daemon::setOption("appName", "min");  // Minimum configuration
    System_Daemon::start();                           // Spawn Deamon!
       ini_set('mysql.default_socket', '/opt/lampp/var/mysql/mysql.sock');
    echo"Nadir";
    $connect = mysql_connect(":/opt/lampp/var/mysql/mysql.sock", "tsas", "rootsas");
if(!$connect)
{die('could not connect to database'.mysql_error());}
mysql_select_db("tsas",$connect);
$query = "INSERT INTO `tsas`.`bus_dtls` (`bus_no`, `gps_id`, `eng_no`, `bus_type`, `no_seats`, `mob_no`) VALUES ('kkd090', '123221', '8008789', 'FP', '', '9895393911')";
$result = mysql_query($query);
?>


and i have saved it as min.php and put in init.d

while running i get the error as:

Code: Select all

root@debian-nadir:/home/nadir# ./min.php
[Feb 24 22:53:10]   notice: starting min daemon, output in: /var/log/min.log
[Feb 24 22:53:10]  warning: min daemon orphaned pidfile found and removed: /var/run/min/min.pid [l:981]
Nadircould not connect to databaseCan't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
can u figure it out where my problem is??
pls help...
thanks in advance

Re: System_daemon:how to change mysql socket path?

Posted: Wed Feb 24, 2010 12:26 pm
by AbraCadaver
That was just an example based upon the default mysql.sock filename, which by default is in /tmp. I have no idea what yours is called or where it is. Mine is /var/run/mysqld/mysqld.sock. Try:

Code: Select all

netstat -l | grep mysql