titov_andrei
@titov_andrei
All my life I learn - and die a fool!

Как выполнить миграцию базы данных в Laravel?

Пытаюсь выполнить миграцию - выходит ошибка - что настроить?

andrew@HIGH-PC e:\OSPanel\domains\laravel-todoapp
> php artisan migrate -v

   Illuminate\Database\QueryException  : SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravel_todoapp and table_name = migrations)

  at E:\OSPanel\domains\laravel-todoapp\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::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)")
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68

  2   PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=laravel_todoapp", "root", "063", [])
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:68

  3   Illuminate\Database\Connectors\Connector::createPdoConnection("mysql:host=127.0.0.1;port=3306;dbname=laravel_todoapp", "root", "063", [])
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:44

  4   Illuminate\Database\Connectors\Connector::createConnection("mysql:host=127.0.0.1;port=3306;dbname=laravel_todoapp", [])
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connectors\MySqlConnector.php:24

  5   Illuminate\Database\Connectors\MySqlConnector::connect()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php:183

  6   Illuminate\Database\Connectors\ConnectionFactory::Illuminate\Database\Connectors\{closure}()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:915

  7   call_user_func(Object(Closure))
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:915

  8   Illuminate\Database\Connection::getPdo()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:940

  9   Illuminate\Database\Connection::getReadPdo()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:399

  10  Illuminate\Database\Connection::getPdoForSelect()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:325

  11  Illuminate\Database\Connection::Illuminate\Database\{closure}("select * from information_schema.tables where table_schema = ? and table_name = ?")
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:657

  12  Illuminate\Database\Connection::runQueryCallback("select * from information_schema.tables where table_schema = ? and table_name = ?", Object(Closure))
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:624

  13  Illuminate\Database\Connection::run("select * from information_schema.tables where table_schema = ? and table_name = ?", Object(Closure))
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Connection.php:333

  14  Illuminate\Database\Connection::select("select * from information_schema.tables where table_schema = ? and table_name = ?")
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Schema\MySqlBuilder.php:18

  15  Illuminate\Database\Schema\MySqlBuilder::hasTable("migrations")
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Migrations\DatabaseMigrationRepository.php:169

  16  Illuminate\Database\Migrations\DatabaseMigrationRepository::repositoryExists()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php:545

  17  Illuminate\Database\Migrations\Migrator::repositoryExists()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php:97

  18  Illuminate\Database\Console\Migrations\MigrateCommand::prepareDatabase()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php:63

  19  Illuminate\Database\Console\Migrations\MigrateCommand::handle()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29

  20  call_user_func_array([])
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:29

  21  Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:87

  22  Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Object(Closure))
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:31

  23  Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), [])
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Container\Container.php:564

  24  Illuminate\Container\Container::call()
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Console\Command.php:183

  25  Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      E:\OSPanel\domains\laravel-todoapp\vendor\symfony\console\Command\Command.php:251

  26  Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Console\Command.php:170

  27  Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      E:\OSPanel\domains\laravel-todoapp\vendor\symfony\console\Application.php:865

  28  Symfony\Component\Console\Application::doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      E:\OSPanel\domains\laravel-todoapp\vendor\symfony\console\Application.php:241

  29  Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      E:\OSPanel\domains\laravel-todoapp\vendor\symfony\console\Application.php:143

  30  Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Console\Application.php:89

  31  Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      E:\OSPanel\domains\laravel-todoapp\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:122

  32  Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
      E:\OSPanel\domains\laravel-todoapp\artisan:37
  • Вопрос задан
  • 661 просмотр
Решения вопроса 2
@EvgeniiR
https://github.com/EvgeniiR
Access denied for user 'root'@'localhost' (using password: YES)
Ответ написан
Комментировать
@iljaGolubev
в .env файле нужно указть параметры подключения:
DB_HOST=localhost
DB_DATABASE=laravel_todoapp
DB_USERNAME=laravel_todoapp_username
DB_PASSWORD=laravel_todoapp_username_password
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 2
@constintmid
Laravel vue.js
Поправь .env фаил он пишет что не может авторизацию в базе пройти
Ответ написан
Комментировать
@rst630
В предыдущих ответах все правильно сказали - убедитесь что логин/пароль/имя базы указаны верно в .env
Но также после изменения .env выполните команду php artisan config:cache что бы сбросить кеш конфигурации - иначе настройки не применятся
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы