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개 답변
0
수락된 답변

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
전문가
답변함 6달 전
profile picture
전문가
검토됨 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인