Re: php cli and mysql
| From: | James Tu | Date: | Tue, 14 Nov 2006 21:03:17 +0000 |
| Subject: | Re: php cli and mysql | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244621@lists.php.net to get a copy of this message | ||
Thanks everyone!
On Nov 14, 2006, at 3:20 PM, bluefx13@gmail.com wrote:
You could make a new php.ini for flexibility like Jochem stated. To make things easy, just copy the file over: cp /usr/local/php5/lib/php.ini /etc/php.ini And that should do it. James Tu wrote:Please see below On Nov 14, 2006, at 2:24 PM, bluefx13@gmail.com wrote:--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpRun this command: /path/to/cli/php -i|grep MYSQL_SOCKETMYSQL_SOCKET => /var/mysql/mysql.sockWhat does that show? It sounds like the PHP module for Apache is using a different php.ini file then the CLI version.I know for a fact that Apache is using: /usr/local/php5/lib/php.iniIt also looks like the CLI versions php.ini is not pointing to the proper path to the mysql.sock. Look under the mysql section of your php.ini and fix that up. To see where its pointing, do this: /path/to/cli/php -i|grep php.iniConfiguration File (php.ini) Path => /etc but when I looked inside /etc there was no php.ini, but there is a php.ini.default... I could create another here... or should I create a symbolic link to the php.ini that Apache is using?That'll tell you where the php.ini file is for the CLI version. Enjoy. James Tu wrote:--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpok. so the location of mysql.sock is a problem. I found it at /tmp/mysql.sock Why is the CLI looking for it at /var/myslq/mysql.sock? Now the question is... Do I change the mysql settings so that mysql.sock is at /tmp/mysql.sock? (If I do, will the PHP module with Apache still be ok?) or Do I change where the CLI is looking for mysql.sock? -James On Nov 14, 2006, at 1:17 PM, cajbecu wrote:--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phptouch /var/mysql/mysql.sock chmod 777 /var/mysql/mysql.sock On 11/14/06, James Tu <jtu@esidesign.com> wrote:--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpI'm running a php script from the command line (I'm on OS X) and I'm getting ... Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) Here's the script (this just tests a connection and a query...the actual script imports data from text files): #!/usr/bin/php <?php echo "HELLO WORLD\n"; $connection = mysql_connect(HOST, ID, PW); mysql_select_db(DB, $connection); $result = mysql_query("SELECT COUNT(*) as num_of_countries from geo_entities"); $row = mysql_fetch_array($result); print_r($row); ?> I tested the script from a browser and the connection and query worked. Do I have to do something special in order for PHP CLI to connect to MySQL? -James --PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php--PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php