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.
System_daemon:how to change mysql socket path?
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: System_daemon:how to change mysql socket path?
In php.ini, change mysql.default_socket or in your script:
Or when connecting:
Or you could link to it in the file system:
Code: Select all
ini_set('mysql.default_socket', '/opt/lampp/var/mysql.sock');Code: Select all
mysql_connect(':/opt/lampp/var/mysql.sock', 'username', 'password');Code: Select all
ln -s /opt/lampp/var/mysql.sock /tmp/mysql.sock
Last edited by AbraCadaver on Wed Feb 24, 2010 12:30 pm, edited 1 time in total.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: System_daemon:how to change mysql socket path?
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.
and i have saved it as min.php and put in init.d
while running i get the error as:
can u figure it out where my problem is??
pls help...
thanks in advance
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'pls help...
thanks in advance
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: System_daemon:how to change mysql socket path?
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 mysqlmysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.