Open yaya-git opened 10 years ago
Check your database login credentials On 3 Jul 2014 12:49, "yaya-git" notifications@github.com wrote:
I try to run: php artisan migrate:install
But I got the following error: Access denied for user 'homestead'@'localhost' (using password: YES)
— Reply to this email directly or view it on GitHub https://github.com/JeffreyWay/Laravel-4-Generators/issues/348.
My credentials are correct, I assign the file config.inc.php $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; My configuration is correct?
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'blog',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
What are the credentials you have set for mysql, and can you connect with those credentials with mysql client? The error you published is coming from mysql. Also what is the default driver you chose in larvae Conlig? On 3 Jul 2014 15:05, "yaya-git" notifications@github.com wrote:
My credentials are correct, I assign the file config.inc.php $cfg['Servers'][$i]['AllowNoPassword'] = TRUE; My configuration is correct?
'mysql' => array( 'driver' => 'mysql', 'host' => '127.0.0.1', 'database' => 'blog', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ),
— Reply to this email directly or view it on GitHub https://github.com/JeffreyWay/Laravel-4-Generators/issues/348#issuecomment-47984762 .
It is clear that you've set your environment to local, so you also need to set your database configuration on your local environment. So go to the app folder > config folder there's a local folder inside of which there's a database.php file. Set your database configurations there and the sky will stop falling on you!
@yaya-git
'mysql' => array(
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => 'blog',
'username' => 'root',
'password' => 'secret',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
In the password field you need "secret" you can read more about the credentials here http://laravel.com/docs/homestead#daily-usage
Also if your running environments and for some reason laravel doesn't see the right one you can call php artisan migrate:install --env="local"
you can read more about the environments here http://laravel.com/docs/configuration#environment-configuration
when connecting from VM, use
user: homestead
pasword: secret
Make sure you login to the VM and go to the directory for your folder there, I found that using migrate artisan from your host (workstation) it fails because the ports are not correct which is true. because the vm uses 3306, while your host would use 33060. One way around this is to make sure your host is not a "local" environment, and set the main app db config as port 33060, and the local db config which would be used on local evironment (make sure your vm is) it will work.
After much gnashing of teeth I was able to solve the problem by adding the port to the host parameter in the mysql array in config/database.php:
'mysql' => [
'driver' => 'mysql',
'host' => '127.0.0.1:33060',
'database' => 'homestead',
'username' => 'homestead',
'password' => 'secret',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
Set 'host' => "10.0.2.2:33060", and then run artisan migrate from within the VM.
Sory, but what if I'm not using any VMs ?
@wattay, Can you try editing .env
file inside on root folder? I got this issue fixed by changing the database and credentials inside this file. Thanks to @huglester
Solved just read this http://tutsnare.com/access-denied-for-user-homesteadlocalhost-laravel-5/
I get similar error on running aimeos on laravel 5 error: SQLSTATE[28000] [1045] Access denied for user 'justin'@'localhost' (using password: NO)
go to your root directory , open .env file:
line 5-8: DB_HOST=localhost DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret
you must change dbname ,username ,password.
I tried to make changes to database.php file present within config folder it looks something like this
'default' => 'mysql',
....
...
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'sample'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
I am not using any VM, I am using my local machine, with the database user as root and password a null.
I have also changed my .env file and it looks something like this:
APP_ENV=local
APP_DEBUG=true
APP_KEY=zLzPMzs5W4FNNuguTmbG8M0iFqhIVnsP
DB_HOST=localhost
DB_DATABASE=sample
DB_USERNAME=root
DB_PASSWORD=null
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
Even after doing all the changes when I try to register using the registration form that is shipped with laravel, I try to add a user to my database I get the following error
In the image we can clearly see that laravel is still trying to connect to homstead database and user, even though I have made changes to all the required places. Can anybody help me in this?
Thanks, Puneet
Update: After doing all the changes I cleared the cache and loaded it again and it seems to work for me now! if any one is also facing the same issue just run the following commands
php artisan cache:clear
php artisan config:cache
I have similar issues. My database is connected to homestead, with standard .env settings
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
and works with the app in the browser but:
php artisan migrate
gives the error:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (usin
g password: YES)
if you use mysql database : you must change dbname ,username ,password in .env file for example:
DB_HOST=localhost
DB_DATABASE=firstapp
DB_USERNAME=root
DB_PASSWORD=
or you must use sqlite database.
I'm using homestead, so my settings are the correct settings for a database in the .env file?. If I use another I won't get the app to work, surely? I have tried and it will not recognise them.
please check the database configuration in the config/database.php file .(Laravel5)
if you are using homestead , so I think that should be like this file ->
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', '127.0.0.1'), 'database' => env('DB_DATABASE', 'homestead'), 'username' => env('DB_USERNAME', 'homestead'), 'password' => env('DB_PASSWORD', 'secret'), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],
I think you should ssh to your homestead and check if everything is working fine.
php artisan config:clear
worked for me :+1:
Anyway thanks @Mohamedalsayed
php artisan cache:clear php artisan config:cache
:+1: :100: Thanks @puneet0191
For me clearing the cache doesn't work. My config is:
$ php artisan tinker
>>> config('database.connections.mysql');
=> [
"driver" => "mysql",
"host" => "localhost",
"database" => "homestead",
"username" => "homestead",
"password" => "secret",
"charset" => "utf8",
"collation" => "utf8_unicode_ci",
"prefix" => "",
"strict" => false
]
If I ssh to the Homestead, I can log in to the mysql with this command:
mysql -u homestead -p homestead
using the 'secret' password.
UPDATE I missed a small detail from the docs. It says that the migrate command should be run from within the VM. That way it works. I was trying to run the command on the host machine where I have a mysql running too. That's why I got the access denied error instead of the connection problem message.
i had this error before , and i have found the solution , just try to clean up you artisan like this :
php artisan cache:clear php artisan config:cache
just it :)
I had this exact problem and I solved it this way: go into the .env and change the host, database, user,password as follows: DB_HOST=localhost DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD=
now use these exact configurations in your database.php it will work just fine
give this error....
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (usin
g password: YES)
Make sure that when running it you are running it on the homestead server. Because your local machine cant connect to the homestead virtual host.
On August 21, 2015 at 6:37:31 PM, lincon sarker (notifications@github.com(mailto:notifications@github.com)) wrote:
give this error....
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (usin
g password: YES)
— Reply to this email directly or view it on GitHub(https://github.com/JeffreyWay/Laravel-4-Generators/issues/348#issuecomment-133580839).
Abby Janke
I think this will fix the problem http://stackoverflow.com/a/32682419/458204
This work for me
Taking this as references: Source
SOLVED: i have the same problem then i checked my database in phpmyadmin then i found out that the database from my phpmyadmin is named "test" and the codes from my . env is DB_DATABASE=kervie. so i changed kervie to test and it work.
i had the same problem what i did is restarting the server (i am using the default server : php artisan serve)
i had the same problem, so i use below artisan commands php artisan cache:clear php artisan config:clear php artisan config:cache my problem get resolved using this
I ran into this error and my solution and clearing the cache did help. Also, I was using PDO for the first time and my query was something like this...
Route::get('/insert', function(){ DB::insert('insert into posts(title, body)values(?, ?)', ['php is great!', 'I love Laravel']); });
My second error was that I didn't separate the title and the body values to be inserted with a COMMA. Hope it helps any one.
I ran into this problem as well while following the tutorial (MVC). Thought I would post comment. Solution with cache and config artisan commands fixed.
I am having this same problem trying to run homestead database:
[PDOException] SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (usin g password: YES)
I have tried everything on this page. Even tried changing DB_HOST to 192.168.10.10. Still cannot php artisan migrate without error. Any other solutions?
check your config/database.php maybe changed user name and password
I was getting this too and fixed it by running migrate from vagrant.
You can also try clearing the cache/config from here too.
I resolve the issue by clearing cache and config and now I can register the user in laravel but it continuously declining to login in auth by this error "These credentials do not match our records.". I had a cross check the database user is registered.
I try to run: php artisan migrate:install
But I got the following error: [PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)