I get a “Connection Refused” error when I run the following batch file:
#!/usr/bin/php
<?php
mysql_connect('127.0.0.1', 'root', '*******');
?>
where * is a working password.
I’ve tried localhost too, but I get the same problem.
I know the password is good because I am able to connect just fine using:
> /Applications/MAMP/Library/bin/mysql -u root -p
I can also connect when I run the script from a browser (but I have to change 127.0.0.1 to localhost).
I’m using MAMP v1.8 on a Mac OS Lion.
Try using this line instead
It should show some more info about the error and if not check to make sure that in phpmyadmin(or SQLbuddy) the user has access to databases(it should because the default ‘root’ should. Also be sure that MAMP is set to online mode.
Also it appears that you missed a “;” at the end of line 2(the line with the connect). Also, you have )) at the end where it should be ); Add that to the end of the line and it should work.