Support the ongoing development of Laravel.io →
Configuration Database
Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

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?

Last updated 1 year ago.
0

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)

Last updated 1 year ago.
0

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)

Last updated 1 year ago.
0

You might have to change the app/config/local/database.php if you're working on your local machine.

Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

Hi, you can see a nice tutorial of Access denied for user ‘homestead’@’localhost’ error solution here

0

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.

0

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.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

hamgomi hamgomi Joined 2 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.