P
P
pochemuchka20202020-03-02 08:11:41
MySQL
pochemuchka2020, 2020-03-02 08:11:41

How to migrate tables from homestead laravel?

I'm trying to make a database migration a command
php artisan migrate
, but it gives me an error connecting to the database. The migration file itself is on the host machine, and I'm trying to execute the command by connecting to the homestead virtual machine with the command
vagrant ssh
Here is the text of the
Illuminate\Database\QueryException error itself: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' ( using password: NO) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')

at /home/vagrant/laravel/vendor/laravel/framework/src/Illuminate/Database/ Connection.php:669

665|         // If an exception occurs when attempting to run a query, we'll format the error
    666|         // message to include the bindings with SQL, which will make this exception a
    667|         // lot more helpful to the developer instead of just the database's errors.
    668|         catch (Exception $e) {
  > 669|             throw new QueryException(
    670|                 $query, $this->prepareBindings($bindings), $e
    671|             );
    672|         }
    673|


Exception trace:

1 PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)")
/home/vagrant/laravel/vendor/laravel/framework/src/ Illuminate/Database/Connectors/Connector.php:70

2 PDO::__construct()
/home/vagrant/laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
Please use the argument -v see more details.

part of .env file
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:XXXXXX+XXXXXXXXXXXXLaXXXXXXXXXXXXXX/XXXXX=
APP_DEBUG=true
APP_URL= 127.0.0.1

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

do you really have to manually create all the columns for the table?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Cyril, 2020-08-28
@levantez

You are using homestead, and most likely you are trying to run "php artisan migrate" locally, but you need to do it from homestead, in the same place where you do "vagrant up", you need to do "vagrant ssh" and run artisan migrate already inside the virtual machine ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question