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 Antwort
0
Akzeptierte Antwort

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
EXPERTE
beantwortet vor 6 Monaten
profile picture
EXPERTE
überprüft vor 2 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen