Issue
I'm trying to follow this guide: https://laravel.com/docs/5.2/quickstart
I'm running ubuntu 14.04 on aws. I'm using laravel 5.2. I'm new to laravel (and aws too for that matter), I've done everything in the guide and get this error.
When I run:
php artisan migrate
I get the following error:
[PDOException]
SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost' (usin g password: YES)
The .env file looks like this:
APP_ENV=local APP_DEBUG=true APP_KEY=hXP0uBJkQos3cHK7D8f6LVx2SLuLAuyv
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525 MAIL_USERNAME=null
MAIL_PASSWORD=null MAIL_ENCRYPTION=null
Edit: Okay, so I guess this problem was due to a lack of understanding of ubuntu, mysql and laravel. I followed the guide in the link above exactly but I guess it was meant for people running homestead. It looks like on an ubuntu server you have to manually create the database (guess it seems obvious to most).
So login to mysql with:
mysql -u root -p
Then enter the password when you are prompted for it.
It's probably not a good idea to use root but I'm just learning so yea. The password you enter here is the same password you have to enter in the .env file in the laravel root directory.
Once logged into mysql enter:
mysql> create database homestead;
This creates a database with the same name as the one specified in the .env file DB_DATABASE=homestead. I should probably change it from homestead as I'm not using homestead :/
The DB_USERNAME is the same username that we use to log into mysql so
DB_USERNAME = root
While the password is the same password we used to log into mysql.
This probably all seems obvious but I'm new and had no idea. It also wasn't covered in the quickstart guide on the laravel website. Maybe I didn't follow it accurately, if so let me know.
Cheers
Solution
As I mentioned you, you need to login to MySQL via terminal mysql -u root -p
, where root is the MySQL user, then input your password, then just create the database using the SQL CREATE DATABASE my_db;
where my_db
is the database name and finally just update your .env file with your database and credentials.
Answered By - enriqg9
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.