I have a problem with my Laravel project. After cloning the repo from git I did
npm install
composer install
php artisan migrate I have an error:
In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost'
(using password: YES) (SQL: select * from languages where status =
1)
In Connector.php line 70:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost'
(using password: YES)
I've added few changes to .env file only
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:q/o7QZeznstW1iBW65t8F7usVPI1oA9osHGaCa6uONU=
APP_DEBUG=true
APP_URL=localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=8889
DB_DATABASE=newDB
DB_USERNAME=root
DB_PASSWORD=root
I am using mamp on mac os for my web environment.
Error Screenshot:
Try adding this to your .env file
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
I use MAMP too and always need this inside my .env files
Open the .env file and edit it.
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:q/o7QZeznstW1iBW65t8F7usVPI1oA9osHGaCa6uONU=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= // Your Database Name
DB_USERNAME= // Yout Database Username
DB_PASSWORD= // Your Database Password
NOTE: If no password is set on the database, clear it DB_PASSWORD
This error basically comes from the after changes in the .env file:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost'
(using password: YES)
After completion of .env edit, must be clear cache: php artisan config:cache
Related
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"
I tried deploying my project to an AWS EC2 server but when I tried to run php artisan migrate I am getting the following error.
PDOException::("SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)")
PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=myDb", "root", "", [])
The following is my .env file:
PP_NAME="MyProject"
APP_ENV=local
APP_KEY=base64:UTBgGqkc11OYbnGGJVe32xFluhFeNw288oH0UcmMYqU=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myDb
DB_USERNAME=root
DB_PASSWORD=
Okay, so I got it fixed. All I did was run php artisan config:clear. The problem was I had a previous migration already done with wrong credentials and everything. So after running php artisan config:clear I went ahead and ran php artisan migrate and everything was fine.
Thanks all for your time.
Here is my Laravel Database config
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=8889
DB_DATABASE=carnet
DB_USERNAME=root
DB_PASSWORD=root
But i keep getting this error
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost'
(using password: YES)
Try changing the host from localhost to 127.0.0.1 and check if it connects.
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..