Access denied for user 'root' @ 'localhost' - Laravel

I have an application with Laravel 4 that works correctly on the local host, but when I downloaded it to my host, I got an error.

app> config> database.php file:

'mysql' => array( 'driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'forum', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), 

And bootstrap> start.php:

 $env = $app->detectEnvironment(array( 'local' => array('homestead'), )); 
+7
php mysql laravel-4
source share
3 answers

You should find out the database host credentials, database name, database name and database password. (If any prefix for tables too), then replace it with current credentials.

Use the concept of the environment and store the values ​​in ENV variables:

http://laravel.com/docs/4.2/configuration

You can save Env Variables as an array in .{ENV_NAME}.env.php and access these variables as $_ENV['variable_name'] .

+3
source share

This worked for me:

 php artisan config:clear 

Even if I changed the config details in the .env file, I got an Access denied error. Executing the above command will clear the configuration cache file, and therefore laravel will read the fresh data from the .env file.

+3
source share

Verify that your mysql database is working fine or not. Then check the db root in mysql without password and restart the server.

+2
source share

All Articles