Oct-10-2021, 02:36 AM
(This post was last modified: Oct-10-2021, 02:36 AM by Pedroski55.)
I have only ever used shared web hosting for my little webpages. That makes things easy for people like me who are not so computer-fit.
Now I have rented a cloud server, using Ubuntu 20.04 Server.
I haven't actually transferred my domain name to the new ip yet, this week I need it on the old hosting.
This bit of ssh tunneling allows me to open phpMyAdmin on the new cloud server from home on my laptop.
Put this:
in the browser on my laptop and I get my login for phpMyAdmin on the cloud server. I can open phpMyAdmin and manipulate tables.
Normally, the function below connects me to my database and gets the information I want, but I on the new cloud server, I just get a timeout error:
Is there some setting I need to adjust on the cloud server??
EDIT The port assigned to me by the cloud server company is 22000 Maybe I need to tell pymysql that??
EDIT: I tried setting pymysql to port=22000 but then I get:
Without port set, pymysql will use port=1443 and I get the timeout error.
Now I have rented a cloud server, using Ubuntu 20.04 Server.
I haven't actually transferred my domain name to the new ip yet, this week I need it on the old hosting.
This bit of ssh tunneling allows me to open phpMyAdmin on the new cloud server from home on my laptop.
Quote:# do this on the local machine
ssh -L 9980:localhost:80 -p 22000 -i ~/.ssh/my_cloud_ed25519 pedro@123.456.789.123
Put this:
Quote:http://localhost:9980/phpmyadmin
in the browser on my laptop and I get my login for phpMyAdmin on the cloud server. I can open phpMyAdmin and manipulate tables.
Normally, the function below connects me to my database and gets the information I want, but I on the new cloud server, I just get a timeout error:
Quote:pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '123.456.789.123' (timed out)")
Is there some setting I need to adjust on the cloud server??
EDIT The port assigned to me by the cloud server company is 22000 Maybe I need to tell pymysql that??
EDIT: I tried setting pymysql to port=22000 but then I get:
Quote:pymysql.err.InternalError: Packet sequence number wrong - got 45 expected 0
Without port set, pymysql will use port=1443 and I get the timeout error.
def mysqlRemoteAttn(clas): # To connect remote MySQL database conn = pymysql.connect( host='123.456.789.123', user='my_sql_user_name', password = 'my_sql_password', db='allstudentsdb', ) cur = conn.cursor() # Select query #cur.execute(f"SELECT studentnr, score FROM allstudentsAnswers{clas} WHERE weeknr = '{weeknr}'") #cursor.execute("SELECT spam FROM eggs WHERE lumberjack = ?", (lumberjack,)) #sql = f"SELECT studentnr, attendance FROM allstudents{clas}" # should be SELECT studentnr, has_been_inc got that wrong in Week 2 #sql = f"SELECT studentnr, has_been_inc FROM allstudents{clas}" sql = f"SELECT studentnr, attn_this_week FROM allstudents{clas}" cur.execute(sql) output = cur.fetchall() #for i in output: #print(i) # To close the connection conn.close() return output # get the attendance from the webpage MySQL results = mysqlRemoteAttn(clas) # put the results in a dictionary studentsAttn = {}