I am using xampp for php project development.
I have a php script which I have to run on terminal. The file needs database connectivity. I have made the connection successfully. I am saying 'successfully' because when I run the script in browser, it runs successfully.
But when I run the script in terminal using,
# php /path/of/the/script.php
I am getting mysql_connect error
PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /opt/lampp/htdocs/project_dir/php-script.php on line 9
It is trying to connect using default mysql's database but default mysql is stopped. XAMPP's mysql is started.
I think if it will connect from XAMPP's mysql database, my script will be run successfully.
I don't want to run following command on terminal.
# wget http://localhost/project_dir/php-script.php
Actually it is working fine but I want to run it using
Please help me to connect to the XAMPP's mysql instead of default mysql.