I am very new to mysql. I made server from amazon lightsail, linux wordpress instance. I know how to connect localhost mysql, so I tried same way.
import pymysql connetion = pymysql.connect(host='xxx.xxx.xxx.xxx', port = 80 user='userid', password='userpw', db='bitnami_wordpress', charset='utf8',) c =connetion.cursor() c.execute("SELECT * FROM 'wp_db7_forms'") result = c.fetchall() print(result)
for host, tried my server public IP, localhost:3306(written in wp-copfig.php),
for port, tried 80 , 8080, 3306
for user and password, tried user, password from wp-config.php and my id and pw from phpmyadmin(which set host as *)
but what I only get is this error
pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query')
wp_db7_froms have only one row, so I don't think error occur because of data amount.
I even tried
from sshtunnel import SSHTunnelForwarder but not worked
how can I connect to remote server wordpress mysql? I just need to read db table.
because my app need to check db before work.