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
- Type
hostname
in your terminal and hit Enter key. This will let you know your hostname (Name of your computer/machine). - In
bootstrap/start.php
file, use this line'local' => array('put-your-hostname-here'),
instead of this line'local' => array('homestead'),
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..
);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..
);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' => '',
),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
How to Parse HTML Table Using PHP
Any PHP Code to Detect the Browser with Version and Operating System
Laravel 5.3 - How to Add Sessions to 'Api' Without Csrf
Reply-To Address in PHP Contact Form
$_Post Empty on Utf-8 Characters
Warning: File_Get_Contents: Failed to Open Stream: Redirection Limit Reached, Aborting
How to Get the Last Dir from a Path in a String
How to Connect to the Database in Openshift Application
How to Pass Variables Between PHP Scripts
Interpreting Return Value of Function Directly as an Array
How to Get the List of Available Locales in PHP
How to Integrate PHPmailer with Codeigniter 3
PHP Loop Counter Bootstrap Row
How to Ignore a Moved-Header with File_Get_Contents in PHP
Is a Blob Converted Using the Current/Default Charset in MySQL