V
V
Vladislav Verilov2022-04-13 07:54:37
MySQL
Vladislav Verilov, 2022-04-13 07:54:37

I can't get data from mysql to laravel, what should I do?

added phpmyadmin on laravel/react assembly everything works fine

wBEti.png

But when I try to get data in json I get an error

Aqb9J.png

Already tried a lot of things, here are env and database files

Env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=fitness
DB_USERNAME=root
DB_PASSWORD=

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'fitness'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', '/var/lib/mysql/mysql.sock'),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

Tell me what's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kuznetsov, 2022-04-13
@inefablecl

Try using host db 127.0.0.1 instead of localhost

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question