4 years ago

Easy way to check if laravel app has connection with existing MySQL DB

Posted 4 years ago by tenzan

I'm going to use an existing MySQL database and have setup in config/database.php :

  'connections' => [

        'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'my-existing-db'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', 'root'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,


Now I need to check if it's able to connect. What's the easiest way?

For example, in Rails it will throw error during server startup if you have any incorrect information on settings.

Please sign in or create an account to participate in this conversation.