connecting to database SQLSTATE[HY000] [1045] on new server - laravel

I have recently changed server and uploaded my database to the server, for the live website i made no changes to my env and everything works the same. But in my php storm development i have had to change the ip(db host) and despite the username and password being the same i am getting an error.
SQLSTATE[HY000] [1045] Access denied for user 'connect'#'xxxxxx' (using password: YES)
I have cleared config and cache and tried launching php artisan again but get the same issue. i have even brought in the env from the server(live website) and changed the DB Host to match the IP of the server but then the error occurs. Does anyone know how i fix this error, could it be an issue with the fact the database was imported from another server?

Related

Why my localhost of phpMyAdmin is showing this error?

Error
MySQL said: Documentation
Cannot connect: invalid settings. mysqli_real_connect(): The server
requested authentication method unknown to the client
[caching_sha2_password] mysqli_real_connect(): (HY000/2054): The
server requested authentication method unknown to the client
phpMyAdmin tried to connect to the MySQL server, and the server
rejected the connection. You should check the host, username and
password in your configuration and make sure that they correspond to
the information given by the administrator of the MySQL server.
Check php version or reinstall xampp

Ping-Connection-Pool throws Access Denied to DB although user exist and credentials are OK

I'm trying to create a jdbc-connection-pool using payara on the console. Using ./asadmin on Payara_Server/bin/
It is Running on Linux and the credentials for the database are user=jc and password=hola123 (dummies), It is for sure this credentials work. I tried them on Mariadb.
I create a connection pool using ./asadmin on Payara, it looks like this:
./asadmin create-jdbc-connection-pool --datasourceclassname org.mariadb.jdbc.MariaDbDataSource
--restype javax.sql.DataSource --property user=jc:password=hola123:DatabaseName=​cinev2:ServerName=localhost:port=3306 cinePool
Now, when I try:
./asadmin ping-connection-pool
I get an error like this:
remote failure: Ping Connection Pool failed for cinePool.
Connection could not be allocated because:
Access denied for user 'jc'#'localhost' to database '​cinev2' Please check the server.log for more details.
Command ping-connection-pool failed.
What would be the causes of this Issue other than Credentials? I have checked if the credentials are right and they are, So I've no clue on the issue.
Since it works when locally connecting to the DB it probably really is an access issue.
Please check if you did all steps outlined here: Access denied for user 'root'#'localhost' (using password: YES) after new installation on Ubuntu

Deploying Laravel to Elastic Beanstalk - DB Connection Refused

I've been developing Laravel app and deploying regularly to an Elastic Beanstalk instance without issue, but suddenly, and without warning, deployments have begun to fail.
Obviously I immediately wondered what I might have changed in the code to cause this, but I haven't made any changes to the core configuration. I rolled back to an earlier commit just to make sure it wasn't my code, and I got the same error.
It's failing after I run eb deploy and running the .ebextensions configs.
Here's the error message from the logs:
[2018-01-08T10:50:34.672Z] INFO [9457] : Running 4 of 5 actions: EbExtensionPostBuild...
[2018-01-08T10:50:35.523Z] ERROR [9457] : Command execution failed: Activity failed. (ElasticBeanstalk::ActivityFatalError) caused by:
In Connection.php line 664:
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = custom and table_name
= migrations)
In Connector.php line 67:
SQLSTATE[HY000] [2002] Connection refused
(ElasticBeanstalk::ExternalInvocationError)
The DB connection credentials are absolutely correct (and haven't changed either).
The command that it's attempting when it fails is simply:
php artisan migrate --force
I've tried connecting over SSH to the server, and I can manually run the same command without issue.
I just can't understand why the deployment is suddenly having its connection refused. Could it be something to do with the AWS security configuration? Could it expire or something? :-/
It turns out the issue was caused by local settings becoming cached and then deployed to the server in: bootstrap/cache/config.php.
Clearing the cache with php artisan config:clear deleted the file and solved the problem.

[PDOException]- SQLSTATE[HY000] [1045] Access denied for user 'root'#'ip' (using password: YES)

I am trying to connect to AWS through ssh in order to migrate some files. I connected successfully using the following command:
ssh -i ~/Downloads/key.pem ec2-user#myuser
Then, I tried to run the following :
php artisan migrate
I got the following:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'user'#'ip' (using password: YES)
What could be preventing me from accessing my DB in order to migrate?!
When you connect to AWS you're connecting to a unix shell account on a virtualize linux server via SSH.
On this virtual server (or maybe another server), you're running an instance of a database application. This database application is also a server. However, it has its own credential system. When you see this error message
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'user'#'ip' (using password: YES)
This is PHP/Laravel telling you
Hey, I tried to connect to the database with the credentials in my app/config/database.php file, but the server told me those credentials were invalid.
In other words, the password you configured for "user" didn't match the actual password, or the "user" account isn't authorized to access the database service (MySQL?) from the IP address PHP is running.
Use the correct database credentials, and your error will go away. Use the command line mysql program to test your database credentials.
Hopefully that's enough to get you Google-ing for the right thing! :)

Laravel Homestead- MySQL default credentials and database

I have setup Laravel and trying to run the artisan migrate command however I am getting the error below
[PDOException] SQLSTATE[HY000] [2002] Connection refused.
I am not sure how db is setup in Homestead. So I got the below questions.
Is default database created automatically by artisan migrate or Homestead?
If it is, what is the name of it?
If its not created by default, should we create before running migration?
I tried logging in to MySQL db by connecting to Homestead VM using ssh and then running MySQL. However I get error Access denied for user.... for user name vagrant, Homestead and forge.
What is the default credentials?
I understand that creating MySQL db is out of the scope of Laravel tutorial; So it would be helpful if anyone can answer these questions and point me in right direction.
Homestead comes with a default database called homestead. Your app can either choose to hook into that database, or you will have to go and make a new database manually. You can either use a GUI (like Sequel Pro on Mac) or perform it via the command line through Vagrant.
// SSH into the box
vagrant ssh
// Connect to MySQL as the homestead user (password is: secret)
mysql -u homestead -p
// Create a new database in MySQL
CREATE DATABASE your_app_name;
// Leave MySQL
exit;
You can then migrate the database as usual, php artisan migrate.
If you need to do this with Postgres instead, it's pretty similar.
// Connect to Postgres (password is: secret)
psql -U homestead -h localhost
// Create a new database in Postgres
CREATE DATABASE your_app_name;
// Leave Postgres
\q

Resources