我想在终端中执行一个简单的php文件:
的script.php
echo "script is running";
$con = mysql_connect("localhost","root","root");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
echo "Connection Established\n";
}
mysql_close($con);
我正在使用php script.php
的MacO终端上运行脚本,我收到以下错误:
script is running
Warning: mysql_connect(): No such file or directory in
/Applications/MAMP/htdocs/issueManager3/notifications.php on line 5
Could not connect: No such file or directory
但是,当我通过Web浏览器运行脚本时,它可以很好地连接到数据库。
我错过了什么吗?或者我需要设置其他东西才能通过终端实现数据库连接?
任何帮助表示感谢。