I am new in Laravel 5.2.
I am getting following error:
[PDOException]
SQLSTATE[28000] [1045] Access denied for user 'homestead'#'localhost' (usin
g password: YES)
While I execute following command:
php artisan migrate
I am running application using vagrant on windows PC.
Please let me know why I am getting above error.
You are getting above error because on your .env file. If you open that from your project base directory then you will following default configuration:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Just change above values according to your development environment. Try again, Hopefully that would resolve your issue.
You must set the database connection in .env file.
Related
SQLSTATE[28000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
**DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=konyayal_yalcinsurucu
DB_USERNAME=konyayal_yalcinsurucuadmin
DB_PASSWORD=xxxxx**
no ssh and terminal option on my hosting.how can i solve?
First you need to check in .env file is everuthing is correct or not like username and password of database.
Once confirm from .env try to execute this command on server =>
php artisan optimize:clear OR sudo php artisan optimize:clear
it will clear all the cache from your projects and take new values from .env and set in cache system.
I hope you will solve your problem of access denied with this small help.
An PDOException(code: 1045) error occurs when laravel connects to mysql yet the credentials allow me to log in via phpmyadmin suggesting the credentials are correct.
Error message:
(PDOException(code: 1045): SQLSTATE[HY000] [1045] Access denied for user 'host.domain.com'#'localhost' (using password: YES)
.env file:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=host.domain.com
DB_USERNAME=host.domain.com
DB_PASSWORD=password_here
PHP version is 7.2.31
Laravel Framework version is 6.13.1
CentOS server (note cant make the error occur on my Windows laptop with WAMP)
If I quoted the DB_DATABASE, DB_USERNAME and DB_PASSWORD fields in .env the application worked. I have no further explanation of why considering there are no spaces in the values for these fields.
Revised .env file:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE="host.domain.com"
DB_USERNAME="host.domain.com"
DB_PASSWORD="password_here"
my code run fine in localhost but when i uploaded it on the serve following error show
Illuminate \ Database \ QueryException (1045)
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO) (SQL: select * from rooms order by order_by asc)
Previous exceptions
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO) (1045)
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:tT9jGFWVeBX5uLy/CVZbs8k+RNGBpMyJ526xfRv3DKQ=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=janatapa_shre
DB_USERNAME=janatapa_shre
DB_PASSWORD=Shre#123
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
though i have changed the database name , user and password in .env file it still says
"Access denied for user 'root'#'localhost' (using password: NO)"
which was my localhost password and user name''
I couldnt even clear my cache
while i was try to use following code on server
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan view:clear
the following error was shown on the terminal
[In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using pas
sword: NO) (SQL: select * from rooms order by order_by asc)
In Connector.php line 70:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using pas
sword: NO) ]1
I also faced this issue, every thing is fine your DB_USERNAME or DB_PASSWORD, if you your password string contains # (for eg. Test123#) "feature"of 5.8 or above it treat # as comment delimiter, so rewrite your password as DB_PASSWORD='Test123#' and its works.
it work for me.
It's due to caching. so delete cache file 'config.php' from bootstrap/cache/config.php . Thanks
I also was facing the same problem! it's due to password string format.
all passwords string contains # (for eg. Test123#. test##, test123$$) must be between quotations
laravel 5.8 above need password to be in a quat
DB_PASSWORD='Test123#'
then run php artisan config:cache then migrate DB through php artisan migrate
it works for me just fine
I have encountered the same error.
SQLSTATE[HY000] [1045] Access denied for user 'niyo'#'localhost' (using password: NO)
I found that I did not create user called niyo and grant to him all privileges. I configured it in user accounts section of PhpMyAdmin interface.
.env file sample
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=oneagentdb
DB_USERNAME=niyo
DB_PASSWORD=123456
When you make changes in .dev you must to this after this changes
php artisan optimize
If everything is ok with the .env file, and you set username and password correct. Then in your project's path open the terminal and use this command,
php artisan cache:clear
I hope it'll be helpful.
When I type "php artisan migrate" in terminal I see the error below:
In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES) (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations)
In Connector.php line 67:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES)
I'm using mac and Mamp Pro,
**Some other informations: **
php artisan serve => Laravel development server started: http://127.0.0.1:8000
.env file =>
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=1234
In phpMyAdmin top of all things writed =>
Server: localhost:8889
Local host address when mamp pro ran =>
http://localhost:8888/phpMyAdmin/
In phpMyAdmin =>
DB name: laravel
Username: root
Pass: 1234
This happens when your credentials cannot connect to the defined sql host.
Ideas:
Can you connect with your db credentials using Sequel Pro? https://www.sequelpro.com.
Be sure you grant laravel db permissions for your user.
Try changing
DB_HOST=127.0.0.1
to
DB_HOST=localhost
I'm getting this error message when I try to migrate using artisan
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [1045] Access denied for user 'myuser'#'mycomputerip'
(using password: YES) (SQL: select * from information_schema.tables where t
able_schema = database and table_name = migrations)
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'myuser'#'mycomputerip'
(using password: YES)
I have tryed to use my local xampp mysql database and that did also not work.
I'm using mariadb on the server which is the one I'm trying to connect to.
env file (default chagnes bcus security)
DB_CONNECTION=mysql
DB_HOST=serverip
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=myuser
DB_PASSWORD=mysecurepassword
I am able to connect using a normal php mysqli connection or with phpmyadmin
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=database
DB_USERNAME=myuser
DB_PASSWORD='' or DB_PASSWORD=mypassword
And
php artisan config:clear
and Then Restart Your serve and Then Try it..