Laravel Access Denied for User 'Root'@'Localhost' (Using Password: Yes) in Laravel 4.2

Laravel Access denied for user 'root'@'localhost' (using password: YES) in laravel 4.2

Laravel 4.x doesn't even support ENV files. You just have to see whether settings in ./config/[env name]/database.php are correct.

Laravel auth: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

One last possibility would be that your server is forcing the value of the env variable DB_PASSWORD ether through Vhost or .htaccess

To verify this, try changing your .env variable to DB_T_PASSWORD=12345678! and dont forget to change it in database.php config file 'password' => env('DB_T_PASSWORD', ''),

Laravel 4.2 + MySQL Running phpunit on Codeship says '.. access denied for user root@localhost ..'

SOLVED:

Setup Commands

# Set php version through phpenv. 5.3, 5.4 and 5.5 available
phpenv local 5.4
# Install extensions through Pecl
# yes yes | pecl install memcache
# Install dependencies through Composer
composer install --prefer-source --no-interaction
php artisan migrate
php artisan db:seed

Test Command(s)

phpunit

Environment Variables

APP_ENV = codeship 
APP_HOST = localhost
APP_DB = test

Laravel 4.2: (Access denied for user 'homestead'@'localhost') error

  1. Type hostname in your terminal and hit Enter key. This will let you know your hostname (Name of your computer/machine).
  2. In bootstrap/start.php file, use this line 'local' => array('put-your-hostname-here'), instead of this line 'local' => array('homestead'),
  3. In .env.local.php file, save your local database configuration like this:

    <?php

    return array(

    "DB_NAME" => "local_database_name",
    "DB_USERNAME" => "local_database_username",
    "DB_PASSWORD" => "local_database_password",

    // any other configuration..

    );
  4. In .env.php file, save your remote database configuration like this:

    <?php

    return array(

    "DB_NAME" => "remote_database_name",
    "DB_USERNAME" => "remote_database_username",
    "DB_PASSWORD" => "remote_database_password",

    // any other configuration..

    );
  5. In app/config/database.php file, set your database connection like this:

    'mysql' => array(
    'driver' => 'mysql',
    'host' => 'localhost',

    'database' => $_ENV['DB_NAME'],
    'username' => $_ENV['DB_USERNAME'],
    'password' => $_ENV['DB_PASSWORD'],

    'charset' => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix' => '',
    ),
  6. Finally, you MUST remove or disable any working code exists in app/config/local/database.php file, otherwise the error you mentioned will be thrown.



Related Topics



Leave a reply



Submit