开发者

mySQL connection issue when migrating from webserver to MAMP

开发者 https://www.devze.com 2023-02-03 17:56 出处:网络
OK so I\'ve recently moved to MAMP for a project using PHP and mySQL. I开发者_运维百科\'ve set up the database and copied all the data but now the script doesn\'t work. I haven\'t changed the default

OK so I've recently moved to MAMP for a project using PHP and mySQL. I开发者_运维百科've set up the database and copied all the data but now the script doesn't work. I haven't changed the default username or password. Any ideas? Here's the code I'm using, it fails at connecting to the database.

<?php
$dbhost = "localhost";
$dbname = "test";
$dbuser = "root";
$dbpass = "root";

mysql_connect("$dbhost", "$dbuser", "$dbpass") or die (mysql_error());
mysql_select_db("$dbname") or die(mysql_error());
?>


Check what value php.ini has for the default mysql socket - MAMP creates one in /Applications/MAMP/tmp/mysql whereas the mysql default location is /tmp

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号