vendredi 28 juillet 2017

Laravel 5.4 : Cannot connect to database on online server

I have just uploaded a Laravel project to a web server but it cannot be connected to the database. I have imported the database to phpmyadmin, and have also set the .env and config/database.php file. When I run the page, it still shows me my localhost database settings (username, password, database etc).

This is my .env file

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:qvuzPrZW3awGcn8etObsyAT7SaKRfgr6AHfpnUPfygE=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://findajob.af/

DB_CONNECTION=mysql
DB_HOST=e73573-mysql.services.easyname.eu
DB_PORT=3306
DB_DATABASE=database_name_on_server
DB_USERNAME=username_on_server
DB_PASSWORD=password_on_server

This is my config/database.php file

'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', 'e73573-mysql.services.easyname.eu'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'database_name_on_server'),
            'username' => env('DB_USERNAME', 'username_on_server'),
            'password' => env('DB_PASSWORD', 'password_on_server'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

When I load the page, it gives me following errors:

QueryException in Connection.php line 647:
SQLSTATE[HY000] [2002] Connection refused (SQL: )

And

1. in Connector.php line 68
2. at PDO->__construct('mysql:host=127.0.0.1;port=3306;dbname=databasename_on_localhost', 'localhost_username', 'localhost_password', array(0, 2, 0, false, false)) in Connector.php line 68



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire