简体   繁体   English

php artisan migrate - 错误 - Illuminate\Database\QueryException: SQLSTATE[HY000] [2054]

[英]php artisan migrate - Error - Illuminate\Database\QueryException : SQLSTATE[HY000] [2054]

I have the following error upon doing:执行时出现以下错误:

php artisan migrate

Error:错误:

Illuminate\Database\QueryException: SQLSTATE[HY000] [2054] The server requested authenti cation method unknown to the client (SQL: select * from information_schema.tables where table _schema = d1 and table_name = migrations) Illuminate\Database\QueryException: SQLSTATE[HY000] [2054] 服务器请求客户端未知的身份验证方法(SQL:select * 来自 information_schema.tables,其中 table _schema = d1 和 table_name = migrations)

Here's a screenshot;这是截图;

在此处输入图像描述

PS.附言。 Just in case: I've enabled the "extension=pdo_mysql" in my php.ini file.以防万一:我在我的php.ini文件中启用了“extension=pdo_mysql”。

Any ideas how to fix this?任何想法如何解决这一问题?

Hi as mentioned in this post:嗨,正如这篇文章中提到的:

Laravel-news Laravel-新闻

it is a typical windows problem.这是一个典型的Windows问题。

The mentioned solution is:提到的解决方案是:

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

inside the AppServiceProvider.php在 AppServiceProvider.php 里面

I have also been stuck on this for quite some time.我也被困在这个问题上很长一段时间了。 One solution that worked for me was to open Connection.php and either comment out the exceptions or replace those exceptions so that there is no error when php migrate is run.对我有用的一种解决方案是打开 Connection.php 并注释掉异常或替换这些异常,以便在运行php migrate时没有错误。 This worked for me.这对我有用。 Let me know if you find any other solutions/any changes.如果您发现任何其他解决方案/任何更改,请告诉我。

Alternatively, and perhaps a better solution:或者,也许是更好的解决方案:

In database.php, found under app/config, add this:在 app/config 下的 database.php 中,添加以下内容:

'connections' => [

    'mysql' => [
        'driver'      => 'mysql',
        'host'        => env( 'DB_HOST', '127.0.0.1' ),
        'port'        => env( 'DB_PORT', '3306' ),
        'database'    => env( 'DB_DATABASE', 'forge' ),
        'username'    => env( 'DB_USERNAME', 'forge' ),
        'password'    => env( 'DB_PASSWORD', '' ),
        'unix_socket' => env( 'DB_SOCKET', '' ),
        'charset'     => 'utf8mb4',
        'collation'   => 'utf8mb4_unicode_ci',
        'prefix'      => '',
        'strict'      => true,
        'engine'      => null,
        'modes'       => [
            'ONLY_FULL_GROUP_BY',
            'STRICT_TRANS_TABLES',
            'NO_ZERO_IN_DATE',
            'NO_ZERO_DATE',
            'ERROR_FOR_DIVISION_BY_ZERO',
            'NO_ENGINE_SUBSTITUTION',
        ],
    ],
],

If you use Macos+docker+mysql.如果你使用 Macos+docker+mysql。 then use this然后用这个

 ./vendor/bin/sail artisan migrate

not php artisan migrate不是 php artisan 迁移

Run the following two commands for ubuntu:针对 ubuntu 运行以下两条命令:

sudo apt install php-mysql
sudo /opt/lampp/lampp restart

Been struggling with this problem too.也一直在为这个问题苦苦挣扎。 I think it's better to drop and then migrate again the tables first before adding a new table or any changes to your migrations folder.我认为最好先删除然后再迁移表,然后再添加新表或对迁移文件夹进行任何更改。 I hope this will solve your problem..我希望这能解决你的问题..

php artisan migrate:fresh

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 php artisan migrate Illuminate\\Database\\QueryException SQLSTATE[HY000] [2054] 上的异常 - Exception on php artisan migrate Illuminate\Database\QueryException SQLSTATE[HY000] [2054] Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] 在文件 Illuminate/Database/Connection.php 上的第 678 行 - Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] in file Illuminate/Database/Connection.php on line 678 Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table - 在克隆项目中 - Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project Laravel 6-MariaDB 10.1:Illuminate \\ Database \\ QueryException:SQLSTATE [HY000]迁移错误 - Laravel 6 - MariaDB 10.1: Illuminate\Database\QueryException : SQLSTATE[HY000] migration error Illuminate\Database\QueryException:SQLSTATE[HY000]:一般错误:1813 Tablespace for table - Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 1813 Tablespace for table Laravel 6 - Mysql - Docker - Illuminate\Database\QueryException SQLSTATE[HY000]:一般错误:2036 - Laravel 6 - Mysql - Docker - Illuminate\Database\QueryException SQLSTATE[HY000]: General error: 2036 Docker Laravel 迁移错误 Illuminate\Database\QueryException SQLSTATE[HY000] - Docker Laravel migration error Illuminate\Database\QueryException SQLSTATE[HY000] laradock php 工匠:迁移 SQLSTATE[HY000] [2002] - laradock php artisan:migrate SQLSTATE[HY000] [2002] Laravel - php artisan migrate - SQLSTATE[HY000] [14] 无法打开数据库文件 - Laravel - php artisan migrate - SQLSTATE[HY000] [14] unable to open database file Laravel SQLSTATE[HY000] [1049] 未知数据库 + PHP 工匠迁移 - Laravel SQLSTATE[HY000] [1049] Unknown database + PHP artisan migrate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM