Laravel: SQLSTATE[28000] [1045] Access denied for user 'homestead'@'localhost'

I tried to make changes to database.php file present within config folder it looks something like this

'default' => 'mysql',
....
...
'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'sample'),
            'username'  => env('DB_USERNAME', 'root'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

I am not using any VM, I am using my local machine, with the database user as root and password a null.

I have also changed my .env file and it looks something like this:

APP_ENV=local
APP_DEBUG=true
APP_KEY=zLzPMzs5W4FNNuguTmbG8M0iFqhIVnsP

DB_HOST=localhost
DB_DATABASE=sample
DB_USERNAME=root
DB_PASSWORD=null

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null

Even after doing all the changes when I try to register using the registration form that is shipped with laravel, I try to add a user to my database I get the following error

laravel database connection error

After doing all the changes I cleared the cache and loaded it again and it seems to work for me now! if any one is also facing the same issue just run the following commands

php artisan cache:clear
php artisan config:cache

I figured it out :) Had to chance the .env file :)

Is there any changes in the schemaes?

Shouldn't this work:

public function up()
{
    // Create table with columns
    Schema::create('users', function($table) {
        $table->increments('id');
        $table->string('username');
        $table->string(Hash::make('password'));
        $table->string('firstname');
        $table->string('lastname');
        $table->string('email')
        $table->string('role');
        $table->timestamps();
    }); 

}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    // Insert table to database
    Schema::drop('users');
}

Tags:

Pdo

Laravel