ybr-nx / laravel-mariadb

Add MariaDB JSON select support to Laravel
95 stars 7 forks source link

DefaultConnection #14

Open Smulllyn112 opened 5 years ago

Smulllyn112 commented 5 years ago
'connections' => [

    'defaultconnection' => [
        'driver' => 'mariadb',
    ],

I set this to the database.php and it dont work to me. Can you help me a little pls? How to set the deafult database exactly? What about the .env file?

Thanks

joveice commented 5 years ago

Are you on laravel 5.3 or 5.4? That is a laravel 5.3 and 5.4 specific configuration.

If you are on 5.5 or higher you could do this, if you are on 5.3 or 5.4 I cannot provide any help as I have not worked with Laravel much before 5.5. I'm currently at 5.8 but it would be the same for 5.5+ and I simply added this under connections in database.php

'mariadb' => [
            'driver' => 'mariadb',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
        ],

now I can just do this in .env

DB_CONNECTION=mariadb
DB_HOST=localhost
DB_PORT=3306

or just change out mysql to mariadb under mysql in database.php like this: Before:

'mysql' => [
            'driver' => 'mysql',

After:

'mysql' => [
            'driver' => 'mariadb',