在mamp中连接数据库1045时发生错误

I want to Create a form and link user information in the databases, but faced a problem when a link "Error occured while connecting with database 1045 in mamp ",

my sirver is MAMP

this is my code for form , index.php is file form and connect.php is code connect with mysql index.php

<?php

include("connect.php");
if (isset($_POST['submit']))
{

$firstName =$_POST['fname'];
$lastName =$_POST['lname'];
$email =$_POST['email'];
$password =$_POST['password'];
$passwordCOnfirm =$_POST['passwordCOnfirm'];
$image =$_FILES['image']['name'];
$tmp_image =$_FILES['image']['tmp_name'];
$imageSize=$_FILES['image']['size'];

}

 ?>

<!doctype html>

<html>
<head>
    <title>regestration Page</title>
  <link rel="stylesheet" href="css/styles.css"/>
</head>
<body>

    <div id="wrapper">

<div  id="#formDiv">

    <form method="POST" action ="index.php" enctype="multipart/form-data">
            <label>First Name </label><br/>

        <input type="text" name="fname"/><br/><br/>

            <label>last Name </label><br/>
    <input type="text" name="lname"/><br/><br/>

        <label>Email </label><br/>
    <input type="text" name="email"/><br/><br/>

        <label>Password </label><br/>
        <input type="password" name="password"/><br/><br/>
        <label>Password Confirm </label><br/>

        <input type="$passwordCOnfirm" name="$passwordCOnfirm"/><br/><br/>

            <label>Image </label><br/>
        <input type="file" name="image"/><br/><br/>


        <input type="submit" name="submit"/>

    </form>
</div>

  </div>

</body>
</html>

connect.php

<?php

    $con = mysqli_connect("localhost","root","root","registration");

    if(mysqli_connect_errno())
    {
        echo "Error occured while connecting with database ".mysqli_connect_errno();
    }


?>

If you are sure your MySQL database is running and your username and password are correct, then you should try connecting to host 127.0.0.1 instead of 'localhost', which is interpreted as a 'socket' connection.