Basic structure in database.php:
'driver' => 'mysql', 'database' => 'database', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '',
If what I think is right, I think you set 'username' to ' ' (nothing in between) so he can't connect you, try to see in app/config/database.php if username is the one you use to connect.
It looks like artisan might be working in the wrong environment. Run "php artisan tinker", then "App::environment();" to see which environment Artisan is running in. If it is something other than production, you need to create a folder with that environments name within your app/config folder, and put a copy of the "database.php" file in it.
camronmatschek said:
It looks like artisan might be working in the wrong environment. Run "php artisan tinker", then "App::environment();" to see which environment Artisan is running in. If it is something other than production, you need to create a folder with that environments name within your app/config folder, and put a copy of the "database.php" file in it.
App::environment(); command did not working Is there any other option?
Hi! I think that you haven't changed the config of the database, if so, go to your project file then "app/config/database.php" then just change the database name to yours name. (in mysql array)
What database name is it looking for? I'm trying to follow the Quickstart instructions and do the initial migration. But I keep getting an access denied message:
Access denied for user 'homestead'@'localhost' (using password: YES)
app/config/database.php lists the db name as "forge" by default. I have the default user and pw entered.
Hi! I think that you haven't changed the config of the database, if so, go to your project file then "app/config/database.php" then just change the database name to yours name. (in mysql array)
You might have to change the app/config/local/database.php if you're working on your local machine.
Yes, I am working on my local machine (I'm new to working with Vagrant). Maybe that's the issue. For the db name, I've tried "Homestead", 'homestead", "forge","", "database"... for the name. MySQL Pro indicates that the database name is "homestead". Perhaps I need to change the host, or try working within the Vagrant environment.
pogachar said:
You might have to change the app/config/local/database.php if you're working on your local machine.
OK, my bad. I needed to run the migrate command from within the vagrant env. Working with a VM is going to take some to to get used to.
silphium said:
OK, my bad. I needed to run the migrate command from within the vagrant env. Working with a VM is going to take some to to get used to.
I had the same problem when I first used Homestead. But a fresh install of Laravel is configured to work with it, it just takes some time getting used to it.
Hi, you can see a nice tutorial of Access denied for user ‘homestead’@’localhost’ error solution here
I was getting the same message, and spent a day resolving. Starting with a new Laravel 5.0.16 installation, .env was correct, Artisan was using the right environment verified by tinker, and the configuration cache was cleared. Issue was the empty username. For some strange reason the database name changed with the environment settings, but the username was always blank. Spent lots of time looking at Artisan code and forcing the username deeper and deeper into the connection code.
Turned out the issue was with MySQL. The SQLSTATE error message is being passed directly from MySQL. I had created the database in PHPMyAdmin by going to Users, Add User, and checked the box "Create database with same name and grant all privileges." So then I had the database and the user, and everything looked cool till I tried to run a migration with the proper environment and got the message above.
After much frustration, I tried to connect to the database with the mysql command-line client and lo, got the same error message. So then I deleted the database and user. Re-created the database in the Databases tab of PhpMyAdmin and separately added the user and privileges. This fixed the issue. I could connect from the MySQL client and run migrations. Don't understand yet what was broken. But moral is, if environment configuration is correct check DB credentials in MySQL client.
I had a similar issue with Laravel 5 refusing database access for the root user. I created a new user, laravel, and a new password in MYSQL. I updated the .env file to include the new database user credentials. Then, I issued GRANT ALL on <name_of_my_database>.* to laravel@localhost; in MYSQL. This worked.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community