dimanche 5 février 2017

Cann't connect to remote database using php

I have Xampp installed in windows and I am creating an application using Laravel 5.3. I am trying to execute a query on another server on local network but when I try to do that the MySql server authenticate the user that is on my local server with is (username: "root" && password:"") while the remote server have (username: "root" && password:"root") and i don't know why. here is my laravel connection under config/database.php

'smsgateway' => [
                'driver'    => 'mysql',
                'host'      => '**.**.**.**',
                'database'  => 'database',
                'username'  => 'root',
                'password'  => 'root',
                'charset'   => 'utf8',
                'collation' => 'utf8_unicode_ci',
                'prefix'    => '',
                'strict'    => false,
    ],

how i use the connection

  $smsgateway =  \DB::connection('smsgateway');
        // dd($smsgateway);
        $smsgateway->statement($sql);

I tried to connect using a native PHP code but I face the same problem here is my code

$servername = "**.**.**.**;
$username = "root";
$password = "root";

try {
    $conn = new PDO("mysql:host=$servername;dbname=database", $username,      $password);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully"; 
    }
catch(PDOException $e)
    {
    echo "Connection failed: " . $e->getMessage();
    }

it gives me Connection failed: SQLSTATE[HY000] [1045] Access denied for user 'root'@'myIPAddress' (using password: YES)



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2jOdH8d
via IFTTT

Aucun commentaire:

Enregistrer un commentaire