duanbi6522 2018-10-26 15:11
浏览 55

laravel中的迁移错误

I am trying to migrate a table to a database called kokodb in laravel. However, I keep getting this error :

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = kokodb and table_name = migrations)

This is my env file:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=kokodb
DB_USERNAME=*****
DB_PASSWORD=*****

and this is the database.php code:

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'kokodb'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', 'ZAQ!2wsx'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,

What is the possible solution to this error?

  • 写回答

3条回答 默认 最新

  • doudang9147 2018-10-26 15:15
    关注

    For me, actually running artisan commands inside the workspace container solved the same problem I had. Check out the Laravel run artisan commands.

    And adding following code at the end of config/database.php, afert 'engine':

            'modes'  => [
                'ONLY_FULL_GROUP_BY',
                'STRICT_TRANS_TABLES',
                'NO_ZERO_IN_DATE',
                'NO_ZERO_DATE',
                'ERROR_FOR_DIVISION_BY_ZERO',
                'NO_ENGINE_SUBSTITUTION',
            ],
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥15 帮我写一个c++工程