我收到以下错误:
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'database-1.cigonpj6rrzl.us-east-1.rds.amazonaws.com:3306' (10060 A connection attempt failed because the connected party did一段时间后没有正确响应,或者由于连接的主机没有响应而建立连接失败)
我的python代码如下:
import mysql.connector
import boto3
import json
client = boto3.client('secretsmanager')
response = client.get_secret_value(
SecretId='dev/test/database-1'
)
secretDict = json.loads(response['SecretString'])
mydb = mysql.connector.connect(
host=secretDict['host'],
user=secretDict['username'],
passwd=secretDict['password'],
database=secretDict['dbname'],
port=secretDict['port']
)
mycursor = mydb.cursor()
sql = "CREATE USER 'new_master_user'@'%' IDENTIFIED BY 'password'"
sql1 = "GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, PROCESS, REFERENCES, INDEX, ALTER, SHOW DATABASES, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER ON *.* TO 'new_master_user'@'%' WITH GRANT OPTION"
mycursor.execute(sql)
mycursor.execute(sql1)
mydb.commit()
print("New user created")
我尝试了对所有流量以及仅对我的 IP 开放的安全性。我哪里错了?