Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8031461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:06:28+00:00 2026-06-05T01:06:28+00:00

I get a Connection Refused error when I run the following batch file: #!/usr/bin/php

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:06:29+00:00Added an answer on June 5, 2026 at 1:06 am

    Try using this line instead

    $sqlcon = mysql_connect("localhost", "root", "password") OR die("Could not connect to database: " . mysql_error());
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get the connection.connection_string value from the following hibernate xml file using
When I try to send Push Notifications I get this error: Connection refused, but
I'm trying to get a value from a netcat connection started at a php
I get error org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP
I'm trying to run MPI programs on 8 machines, but I get the error
how to get network connection list in my computer with c# vpn list or
Hi I am trying to get a connection from windows a unix box and
I'm using Fluent NHibernate and need to get my Connection String from the connection.connection_string
I am new to Cocoa, but managed to get a connection (to a FTP)
I get a communication link failure while application tries to establish a connection with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.