Kk Mm
Kk Mm

Reputation: 57

Laravel Hyn/Tenancy Database [tenant] not configured

I followed the tutorial in this web and with homestead, got results right. But, with XAMPP on Windows, when I try to login as a tenant, "Database [tenant] not configured" error occurs.

URL:

https://www.seismicpixels.com/creating-a-laravel-saas-framework-part-1/ https://www.seismicpixels.com/creating-a-laravel-saas-framework-part-2/ (At part-2, step 4, the error occurs and I cannot login as the tenant)

Environment: XAMPP for Windows 7.3.9 PHP 7.3.9 Apache/2.4.41 (Win64) mysql Ver 15.1 Distrib 10.4.11-MariaDB, for Win64 (AMD64)

Laravel Framework 5.8.37 hyn/multi-tenant 5.4.5

I am very new to Laravel and if Im missing any information to ask help, please kindly let me know.

Thank you in advance.


added on 26th

I added 'tenant' in database.php then I get the following error now: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) (SQL: select * from users where email = [email protected] limit 1)

it seems hyn/tenancy cannot get the user database name (uuid) and it's password.

is this hyn/malti-tenant bug?

my database.php------------

'connections' => [

    'system' => [
        'driver' => 'mysql',
        'host' => env('TENANCY_HOST', '127.0.0.1'),
        'port' => env('TENANCY_PORT', '3306'),
        'database' => env('TENANCY_DATABASE', 'tenancy'),
        'username' => env('TENANCY_USERNAME', 'tenancy'),
        'password' => env('TENANCY_PASSWORD', 'tenancy'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

    'tenant' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => '',
        'username' => '',
        /*'database' => '3d118cf757154f6d9be5cb1935078588',
        'username' => 'root',*/
        'password' => '',
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,
    ],

my .env---------------------------

DB_CONNECTION=system 
TENANCY_HOST=127.0.0.1
TENANCY_PORT=3306
TENANCY_DATABASE=tenancy
TENANCY_USERNAME=tenancy
TENANCY_PASSWORD=tenancy

Upvotes: 0

Views: 2519

Answers (1)

Kk Mm
Kk Mm

Reputation: 57

At the end, using stancl/tenancy solved it all. Strongly recommend using stancl now.

https://github.com/stancl/tenancy

Upvotes: 1

Related Questions