I have upload my laravel project to Ubuntu 14 i have install MySQL to the server put a try to run migrations using php artisan migrate i keep getting this error [PDOException] SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using pas sword: YES i dont understand how to fix this.
Asked
Active
Viewed 1,189 times
0
-
Check your password on _mysql_ try signing in with the password you know. If it fails then that's your problem, else check your _laravel .env_ file to make sure you have the right password entered there. – George Udosen Dec 16 '16 at 12:06
-
the MySQL lets my in so the password good but the php migration wont work for me – Ray Brown-amory Dec 16 '16 at 12:20
-
check the password in the _.env_ file in laravel – George Udosen Dec 16 '16 at 12:21
-
Have you checked the password yet ? – George Udosen Dec 16 '16 at 13:20
-
Yes i have George and still nothing – Ray Brown-amory Dec 16 '16 at 13:25
-
it work on local machine when i am using wamp server and MySQL local instance – Ray Brown-amory Dec 16 '16 at 13:26
-
The check was done on the upload machine ? – George Udosen Dec 16 '16 at 13:27
-
yes on my Ubuntu test server and it throws that error i mention – Ray Brown-amory Dec 16 '16 at 13:31
-
I have check the .env files and put a password in there i have put a password in there and still it throws connection errors – Ray Brown-amory Dec 16 '16 at 13:32
-
what version of laravel ? – George Udosen Dec 16 '16 at 13:39
-
is it laravel 5.3 – Ray Brown-amory Dec 16 '16 at 14:04
-
is the information in the _.env_ file like this: DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=database_name DB_USERNAME=root DB_PASSWORD=password. And did you regenerate the _.env_ file at the upload location ? – George Udosen Dec 16 '16 at 14:15
-
No i did not regenerate but where DB_host is just say local host should change that to 127.0.0.1 – Ray Brown-amory Dec 16 '16 at 14:19
-
should use composer up date – Ray Brown-amory Dec 16 '16 at 14:23
-
You are supposed to regenerate the _.env_ at upload location __never upload .env__ and use __composer update__ and then add __DB_HOST=127.0.0.1__ if __localhost__ doesn't work. – George Udosen Dec 16 '16 at 14:26
-
I git add it all should I should git check it out then copy the .env example file ? and change that – Ray Brown-amory Dec 16 '16 at 14:41
-
add it to the __.gitignore__ file as __.env__ then upload your work and the __.env__ will be left out then you can manipulate the __.env.example__ file, but still run __composer update__ to get a knew key __don't copy__ the old one. – George Udosen Dec 16 '16 at 14:46
-
thanks George i sure this is the problem i finish work soon i let you know next week if that was the problem thanks for the help i used stfp to upload and forget to put the env file in the gitignore – Ray Brown-amory Dec 16 '16 at 14:52
-
Ok George thanks for you help was that and the password as well php artisan worked cheers George – Ray Brown-amory Dec 16 '16 at 15:38
-
let me put down answer that you mark as correct, glad it worked out. – George Udosen Dec 17 '16 at 05:11
2 Answers
0
Hi everyone thanks for the advice and help it was because i did not generate the .en file on the server and my password was wrong to so i am happy now
Ray Brown-amory
- 11
- 5
0
According to your issue you uploaded the entire project including the .env file. In Laravel when uploading your finished work they are several things you don't do:
- never upload the .env file instead regenerate a new one using composer update, as this will contain sensitive information that should not moved in that way.
- use the same application key for both location, this will be regenerated when composer update is run at the new location.
Solution:
- add the .env file to the .gitignore file so it's never seen like other files.
- after uploading your work use the included .env.example file, change it to .env then run composer update. Add your database information from the new location there.
- run
composer updateand the new .env file should be ok.
George Udosen
- 35,970
- 13
- 99
- 121