[英]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:嗨,正如这篇文章中提到的:
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.