Amazon EC2 Instance connectivity - amazon-ec2

I have created an ec2 instance and followed all steps according to AWS documentation, But I am unable to connect to database from the php files in html folder. Below is the error
Warning: mysqli_connect(): (HY000/1130): Host
'ip-172-31-28-115.us-west-2.compute.internal' is not allowed to
connect to this MySQL server in /var/www/html/test/test.php on line 11
Unable to connect to MySQL
The Php files are not getting connected to the database that is created on instance.
Note: I also tried creating new user and granted privileges to the new user but no luck!
It would be great if you can assist us through problem, since we have already spent lot of time experimenting on this.

Things to check for MySQL connection:
--/etc/my.cnf to ensure that listening on the right port(s) ip(s). 3306 default.
--Open port 3306 in AWS to ensure that client can access
--Grant privs on database to user that is connecting.
--Examine mysql logs and apache error logs for errors.

can you try running this? I think it has to do with permissions.
GRANT ALL PRIVILEGES ON . TO 'root'#'%';
FLUSH PRIVILEGES;

Related

Local database docker to AWS database in VPN

i'm a beginner to Docker, hope everyone can help, much appreciated.
I downloaded a docker image from my company repository and i managed to create a container in my local machine from the image, let's named it mydb. It is created through command below:
docker run --name mydb -p 1521:1521 -d mycompany.com:5000/docker-db:20.0.04
I am able to access the database with following connection string through my sqldqveloper : system/abc123#127.0.0.1:1521/ORCL
Our company have a database server in AWS, let's name it awsdb. I can access it after vpn login.
I am able to access the database with following connection string in sqldqveloper :
system/abc123#awsdb.amazonaws.com:1521/awsdb
Question:
How can i create a database link in mydb to awsdb with database link "my_dblink"? eg. select sysdate from dual#my_dblink.
I try with following command:
CREATE PUBLIC DATABASE LINK my_dblink
CONNECT TO system
IDENTIFIED BY abc123
USING 'awsdb.amazonaws.com:1521/awsdb';
but it return error ORA-12543: TNS:destination host unreachable.
I tried remove the container and recreated it by set the net=host:
docker run --name mydb -p 1521:1521 -d --net=host mycompany.com:5000/docker-db:20.0.04
then now i can't even connect is with system/abc123#127.0.0.1:1521/ORCL
error ORA-12541 returned: no listener.
How can i open the connection between internal docker to AWS database server? Thank you.
First of all, I do believe you need to understand what you are trying to accomplish.
When you create a database link between two databases, the main requirement you must fulfil is to have network connectivity between both of them in the ports you are using. As one of them is stored in public cloud, at least you would need:
A network connection between the network where the docker is installed and the public cloud in AWS.
But, as your docker is installed in your local laptop, the AWS should be opened to Internet, something that it is a security issue and probably it is not enabled.
Moreover, you would need Firewall rules in all the ports you might need to use in this connectivity.
As you are using a VPN login that allows you to access the AWS Cloud resources because you are connecting through it ( probably using Active Directory and/or a certificate, perhaps even using SSO federation between your AD in your company and the resources in AWS ), the database can't connect using that.
Summarizing, that is not possible, and if I were someone in Security I would never allow it. The only option for you would be to create a docker with the database in AWS and then create the database link there.

Connecting to Aurora AWS Serverless

I’ve now tried to create a serverless Aurora (MySQL compatible) database and connect to it for two days, and I just can’t seem to get it to work. Supposedly I should have been able to get it up and running in five minutes.
In any case, I created am Aurora Serverless database in the US East (N. Virginia) region (us-east-1), and have been able to connect to it with the AWS Query Editor. I also have an EC2 server in the same region, and have given the Aurora database the same security group (under RDS > Security Group), and in the security group I have opened for MYSQL/Aurora (TCP, 3306) from all sources. When I click the modify button on the database, there is also another (VPC) Security Group listed (rds-launch-wizard-4), which was created automatically. This one I also located under my EC2 dashboard and gave access to all ports from all sources (inbound), and to all ports (outbound). And there is a networking VPC & subnet group, which I don’t know what to do with, if anything.
I try to connect to the database, using this command line command:
mysql -h hest2.cluster-xxxxx.us-east-1.rds.amazonaws.com -P 3306 -u root –p
It generates an error “ERROR 2003 (HY000): Can't connect to MySQL server on” on both my EC2 instance, my local computer and on other online servers.
From the EC2 instance, try doing a telnet on the DB port to test if all your security group settings are applied correctly.
telnet hest2.cluster-xxxxx.us-east-1.rds.amazonaws.com 3306
If the connection does go through, then the issue is with your client code. Cross check that you have wired the right endpoint in your code.
If the telnet connection does not group (I'm guessing that it would not), then it is guaranteed that your security group settings are not set correctly. In order to debug this further, we would need more details on:
The list of vpc security groups associated with your cluster.
The details of each of these vpc security groups (You've mentioned that
you've opened up everything, but I'd like to see the exact rules in
place)
As for laptop and other servers - If they are outside the VPC, then it would not work. Aurora Serverless is accessible only from within the VPC as of now.

Laravel: cannot use php artisan migrate with Amazon RDS

I followed every tutorial from Amazon to set up the RDS Database then to set up the VPC, the subnet, and the Security Groups but I still can't connect to the Database using Laravel command.
However, I can connect to the Database using MySQLWorkbench...
This is the error I got when I use the command "php artisan migrate"
Every help will be more than appreciate, thank you Guys.
I'm taking these settings right out of my RDS instance and the Laravel application that uses it.
The first thing you have to do after setting up your RDS database is to allow the database instance to be accessed publicly. This can be done from your AWS console by going to RDS > DB Instances > your database instance > Modify (top left corner). Then scroll down to the Network and Security section and select 'Yes' for public accessibility.
Also double check your Security groups to make sure there is a rule allowing incoming connections to port 3306.
In your Laravel application's .env file and update the database values.
DB_HOST should contain the endpoint specified on the Connectivity and security section of the RDS dashboard. DB_PORT should remain at 3306. Then specify the database name in DB_DATABASE and the database credentials in DB_USERNAME and DB_PASSWORD.
These are the settings I'm using to connect my Laravel application to an RDS MySQL database.
It's difficult to say but it looks like you have the incorrect DB name.
Double check your RDS db name and the environment variable DB_DATABASE

MemSQL - unable to connect remotely to EC2 cluster using MySQL client

I have used http://cloud.memsql.com to successfully deploy a MemSQL cluster to EC2 as documented here: http://docs.memsql.com/4.0/setup/setup_cloud/.
I can SSH to the master aggregator, and successfully login to the MemSQL prompt locally. However, I cannot connect remotely using a MySQL client application.
I have double-checked port 3306 is open and just for testing have applied all privileges to root:
GRANT ALL PRIVILEGES ON *.* TO root#'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
The documentation states:
Once your cluster is up and running, connect to the master aggregator using any valid MySQL client driver.
Can anyone advise on a step I have missed?
--
UPDATE 1 - The source range is open for the MemSQL port:
3306 tcp 0.0.0.0/0
UPDATE 2 - ufw has been disabled for testing.
Currently, clusters spun up by cloud.memsql.com lock down their security group to the vpc for the MemSQL ports (like 3306). If you want to access it from outside of the vpc, you will need to add a new rule to the group. Something like this would open the group completely:
Add an Ingress rule for port 3306-3306 for CIDR: 0.0.0.0/0
Note that this will open the cluster to the world, and anyone will be able to connect. Instead of 0.0.0.0/0, I recommend using your public ip and a /32 like so: YOUR_IP/32
It turned out to be a DNS issue by the provider I was using. Tried connecting using a cell phone and had no issues.

error trying to connect to cleardb

Hi again i want to connect to cleardb instance in heroku i take hostname and credentials from heroku config vars in CLEAR_DATABASE_URL but i am getting the following error
ERROR 2003 (HY000): Can't connect to MySQL server on 'us-cdbr-east-06.cleardb.net' (111)
im trying to connect in this way
mysql -u username -p -h us-cdbr-east-06.cleardb.net
any idea why i am getting 111 error?
thanks for your time
Error fixed thanks the help from cleardb support team, here support answer
Hi there,
Thanks for reaching out. You may want to check with your local network
administrator and/or ISP to ensure that you are allowed to access
remote resources that run on TCP 3306. It is possible that this port
has been blocked from your local network and/or machine. To be clear,
we performed a connection test on this database and found that it is
operating normally, so the next diagnostic step is to check your local
connectivity to remote MySQL databases.
Hope this helps,
member team

Resources