MySQL-Probleme bei webgo

Ich hatte gerade ein seltsames Phänomen, dessen Lösung ich hier kurz beschreiben möchte.

Der Webhoster webgo bietet sowohl MySQL als auch MariaDB als Datenbanken an. Bei MySQL soll man laut Doku localhost:3306, bei MariaDB 127.0.0.1:3307 nutzen.

Als ich gerade eine Laravel-Applikation installiert habe, habe ich als Datenbank-Host ‚localhost‘ angegeben, da ich MySQL nutze. Die Migration lief problemlos durch, doch beim Aufruf der Applikation kam ein Fehler. In den Logs war folgender Eintrag zu finden:

Next Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `users` where `system_name` = public limit 1) in /path/to/my/site/vendor/laravel/framework/src/Illuminate/Database/Connection.php:647
Stack trace:
#0 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Database/Connection.php(607): Illuminate\Database\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#1 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Database/Connection.php(326): Illuminate\Database\Connection->run('select * from `...', Array, Object(Closure))
#2 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1718): Illuminate\Database\Connection->select('select * from `...', Array, true)
#3 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1703): Illuminate\Database\Query\Builder->runSelect()
#4 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(493): Illuminate\Database\Query\Builder->get(Array)
#5 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(477): Illuminate\Database\Eloquent\Builder->getModels(Array)
#6 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(409): Illuminate\Database\Eloquent\Builder->get(Array)
#7 /path/to/my/site/app/User.php(45): Illuminate\Database\Eloquent\Builder->first()
#8 /path/to/my/site/app/helpers.php(37): BookStack\User::getDefault()
#9 /path/to/my/site/app/Http/Middleware/Localization.php(18): user()
#10 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): BookStack\Http\Middleware\Localization->handle(Object(Illuminate\Http\Request), Object(Closure))
#11 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#12 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#13 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))
#14 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#15 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#16 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#17 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#18 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#19 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#20 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#21 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#22 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#24 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#25 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(561): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#26 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(520): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#27 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Router.php(498): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#28 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(174): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#29 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#30 /path/to/my/site/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#31 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#32 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#33 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#34 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#35 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#36 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#37 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#38 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#39 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))
#40 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(149): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#41 /path/to/my/site/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#42 /path/to/my/site/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#43 {main} 

Nach einigem Suchen und Ausprobieren war die Lösung ganz einfach: Entgegen der Angabe muss für für den DB-Host ‚127.0.0.1‘, nicht ‚localhost‘ angegeben werden. Direkt nach dem Ändern hat dann alles funktioniert.

Schreibe einen Kommentar