Issue
I have two ec2 instances running laravel projects using ubuntu 20.04 on both instances. Both instances are running fine. One instance contains a database which is also working with one project but I want the same database to connect with the other laravel project while sitting in other EC2 instance. So here is what I means.
2 EC2 instances (Ubuntu 20.04). Let's call them (Instance A & Instance B)
Instance A has mysql database up and running and connected to the laravel project
Instance B also required to use database of Instance A. I did it on digitalocean but I am not finding any solution on internet. Any help would be really appreciated
Thank You
Solution
The problem wasn't with instances security groups.
All I had to do was to allow MySQL to listen to connections from remote IP addresses, and for that, I created a new user in MySQL that listens to the connection from the second ip address.
CREATE USER 'new_remote_user'@'ip-address-of-your-instance' IDENTIFIED BY 'pass-of-new-instance';
grant all privileges on *.* to 'new_remote_user'@'ip-address-of-your-instance';
Answered By - Danish Tahir Answer Checked By - Mildred Charles (WPSolving Admin)