Меня попросили создать приложение CRUD с Laravel и Mysql от потенциального работодателя, но я получаю сообщение об ошибке при запуске:
php artisan migrate
Ошибки при запуске php artisan migrate являются:
Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = Laravel-tasks and table_name = migrations)at /Users/my_username/PHP/todo/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|Exception trace:
1 PDOException::("PDO::__construct(): The server requested authentication method unknown to the client [caching_sha2_password]")
/Users/my_username/PHP/todo/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:702 PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=Laravel-tasks", "root", "YGM4QV6kWnjz3uN!", [])
/Users/my_username/PHP/todo/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
Это командная строка, которую я выполнил в папке моего проекта
php artisan make:migration create_tasks_table
Это код на create_tasks_table.php:
bigIncrements('id');
$table->string('title');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('tasks');
}
}
База данных в файле .env является:
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=Laravel-tasks DB_USERNAME=root DB_PASSWORD=*****
Надеюсь на ваши опытные ответы!
Ваше здоровье!
Оригинал: “https://dev.to/highcenburg/php-artisan-migrate-3l3l”