I am trying to connect php file with MySQl Server database in MacBook Air using Terminal. It shows me
Warning: mysqli::__construct(): (HY000/2002): No such file or directory
I have seen many solution in Stack Overflow but I doesn't give the solution. I have tried by giving first parameter as both localhost and 127.0.0.1 but it gives me pic2 given below.
Warning: mysqli_connect(): (HY000/2002): No such file or directory
My PHP code is below:
<?php
$connection = mysqli_connect(':/Applications/MAMP/tmp/mysql/mysql.sock', 'root', '1234');
if (!$connection){
die("Database Connection Failed" );
}
$select_db = mysqli_select_db($connection, '');
if (!$select_db){
die("Database Selection Failed" . mysqli_error($connection));
}
?>