Reputation:
I have downloaded a repo on github and created a database. I am trying to do migrations and am getting the below error
Error:
Illuminate\Database\QueryException : SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge' (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE')
This is my .env file
APP_NAME=Tafuta
APP_ENV=local
APP_KEY=base64:0IDLuBYdTssK55SeeQTmCJ3GHlJXsR6BahTeenXaf90=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=TafutaM
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Upvotes: 3
Views: 6813
Reputation: 341
You have to run the following command if you downloaded the source from GitHub:
composer install
cp .env.example .env
php artisan key:generate
php artisan config:clear
php artisan cache:clear
php artisan migrate
Upvotes: 2
Reputation: 17206
Your .env
is not taken into consideration for the variables.
It might be cause by something in your Vhost configuration
like
A direct declaration of the variable in there that would override .env
variables.
Another environment file
is declared it it to be read. like .env.prod
or .env.dev
Upvotes: 1
Reputation: 598
Many people have this common error: It's because your database is not set.
Error say: '@localhost', then username = ''
database: forge, then database is named = 'forge'
If you dont see that parameters into your .env, its because file is not read, then you have to refresh your configuration:
php artisan config:cache
if you are using php artisan serve
cancel it, and run again.
Now, if problem persists, you have to log with terminal or a database tool to your database, and make sure that the next parameters are the same:
DB_CONNECTION=
DB_HOST=
DB_PORT=
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
Sometimes, people set incorrect port, or username or any(dont forget refresh configuration if you edit .env file).
Upvotes: 0