I'm having problems to create database tables.
First of all I create the models:
php artisan make:model Company -m
Second I update the migration company file, adding the columns that I need
Third I'm going to phpMyAdmin
and create a new database named test
Fourth I run the command php artisan migrate
or php artisan migrate:install
and I have the next error:
[Illuminate\Database\QueryException]SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = test and table_name = migrations)
[PDOException]SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)
In database/config.php
I edit the mysql driver to this:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'test'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'pass'),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
And .env file
:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=test
DB_USERNAME=root
DB_PASSWORD=pass
I also tried to clean cache with php artisan config:clear
.
Anyone can help me? I don't understand what is the problem.
Thank you