I am having trouble connecting to a mysql rds

0

import pymysql

Database connection parameters

endpoint = 'my-endpoint' # your RDS endpoint username = 'admin' # your RDS username password = 'my-password # your RDS password

Establish a database connection

try: connection = pymysql.connect(host=endpoint, user=username, passwd=password) cursor = connection.cursor()

# Create a new database
cursor.execute("CREATE DATABASE test;")
print("Database 'test' created successfully.")

except pymysql.MySQLError as e: print(f"Error connecting to MySQL Database: {e}") finally: # Close the connection if connection: connection.close()

I am running this simple code and getting the error Error connecting to MySQL Database: (2003, "Can't connect to MySQL server on 'my-server-endpoint' (timed out)") I have ensured that the db is publicly accessible and have added a security group that has multiple rules including accepting all traffic, accepting all ipv4 mysql/aurora connections and all ipv6 mysql/aurora connections.

Here are images of my security settings and my publicly accessible section Inbound Rule Settings

Publicly Accessible

1 réponse
0
Réponse acceptée

You say you have added a security group with multiple rules. If you mean you created one, then from your RDS screen shot it’s NOT configured to use this new security group. You’ll see RDS is using the default security group.

Other thing to note a public RDS instance needs to be in a Public subnet.

profile picture
EXPERT
répondu il y a 6 mois
profile picture
EXPERT
vérifié il y a 2 mois

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions