mysql - Laravel 5でMariadbを設定する

原文 mysql laravel pdo laravel-5 mariadb

MariaDBを使用してデータベースをLaravelに接続しようとしましたが、成功しませんでした。アプリを実行すると、次のエラーが返されます。

PDOException in Connector.php line 47:
SQLSTATE[HY000] [1049] Unknown database 'data'


これが私のDatabase.phpファイルです:

'default' => 'mysql',

'connections' => [

        'sqlite' => [
            'driver'   => 'sqlite',
            'database' => storage_path().'/database.sqlite',
            'prefix'   => '',
        ],

        'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

        'pgsql' => [
            'driver'   => 'pgsql',
            'host'     => env('DB_HOST', 'localhost'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset'  => 'utf8',
            'prefix'   => '',
            'schema'   => 'public',
        ],

        'sqlsrv' => [
            'driver'   => 'sqlsrv',
            'host'     => env('DB_HOST', 'localhost'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'prefix'   => '',
        ],

    ],


これが私の.envファイルです:

APP_ENV=local
APP_DEBUG=true
APP_KEY=ZP9Ao5RJhZjS7EqJuaYRltSIC7HTL4vp

DB_HOST=localhost
DB_DATABASE=data
DB_USERNAME=root
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null


このエラーダンプ:

in Connector.php line 47
at PDO->__construct('mysql:host=localhost;dbname=data', 'root', 'secret', array('0', '2', '0', false, '0')) in Connector.php line 47
at Connector->createConnection('mysql:host=localhost;dbname=data', array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'data', 'username' => 'root', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql'), array('0', '2', '0', false, '0')) in MySqlConnector.php line 20
at MySqlConnector->connect(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'data', 'username' => 'root', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in ConnectionFactory.php line 58
at ConnectionFactory->createSingleConnection(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'data', 'username' => 'root', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, 'name' => 'mysql')) in ConnectionFactory.php line 47
at ConnectionFactory->make(array('driver' => 'mysql', 'host' => 'localhost', 'database' => 'data', 'username' => 'root', 'password' => 'secret', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false), 'mysql') in DatabaseManager.php line 177
at DatabaseManager->makeConnection('mysql') in DatabaseManager.php line 65
at DatabaseManager->connection(null) in Model.php line 3134
at Model::resolveConnection(null) in Model.php line 3100
at Model->getConnection() in Model.php line 1895
at Model->newBaseQueryBuilder() in Model.php line 1836
at Model->newQueryWithoutScopes() in Model.php line 1810
at Model->newQuery() in Model.php line 3321
at Model->__call('get', array()) in SongsController.php line 20
at Song->get() in SongsController.php line 20
at SongsController->index()
at call_user_func_array(array(object(SongsController), 'index'), array()) in Controller.php line 246
at Controller->callAction('index', array()) in ControllerDispatcher.php line 162
at ControllerDispatcher->call(object(SongsController), object(Route), 'index') in ControllerDispatcher.php line 107
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 108
at ControllerDispatcher->callWithinStack(object(SongsController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 67
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\SongsController', 'index') in Route.php line 198
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 131
at Route->run(object(Request)) in Router.php line 691
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Router.php line 693
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 660
at Router->dispatchToRoute(object(Request)) in Router.php line 618
at Router->dispatch(object(Request)) in Kernel.php line 210
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 111
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53


MysqlとMariaDBの間の何らかの競合に関係していると思います。すでにMariaDBをLaravelで使用しようとした人が例や経験を提供できたら、助かります。
奇妙なことに、「php artisan:migrate」を使用して移行ファイルを実行でき、データベースには適切なテーブルが存在します。移行スクリプトをデータベースに接続するにはどうすればよいですか?何が悪いのですか?
答え
私は最終的にその動揺を解決しました。私はウェブサイトを実行するためにララベルの迷惑なボックスであるホームステッドを使用していたため、サイトは実際にはホームステッド内にある内部mysqlに接続しようとしており、MariaDBに到達することは決してありませんでした。私はまだHomestead内でMariaDBを使用する方法を理解していませんが、少なくとも検索を絞り込んでいます。
関連記事

php - mysqlおよびphpの実際のランク

c# - WPFアプリをipageサーバーのMySQLデータベースに接続する

php - jqueryでphp文字列を参照しますか?

mysql - WSO2 DSSはタイムゾーン情報をmysqlの日付結果に追加します

php - CodeIgniterは1行ではなく2行挿入します

mysql - nginx上のPHP-FPMが外部MySQLに接続しない

mysql - 日付を週に変換

mysql - MySQLは別のテーブルの値を表示します

php - MYSQLのCaseステートメントでのANDの使用

php - mysqlクエリに基づいて複数のループを実行する