I have a little Python script to collect students' homework and online classwork scores from the table allstudentsAnswers20BE.
This works great on my old shared web-hosting webpage.
On the new Ubuntu 20.04 cloud server, I am getting connection refused. I have no experience running a cloud server.
I allowed ports 33060 and 3306 in UFW
My ip is at home is not fixed.
When I run my Python script I get this error when trying to connect to the cloud server
pymysql.err.OperationalError: (1130, "183.206.16.30' is not allowed to connect to this MySQL server")
netstat says mysqld is listening on 33060 and 3306, so I allowed both in the firewall ufw
Connecting to the cloud server via ssh, I ran:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
I changed the line bind-address to 0.0.0.0 (I also tried *)
I restarted mysql: sudo systemctl restart mysql
There must be something else that needs setting, server side.
Any tips what that might be please, I really need this to work.
I also got this info (assume my cloud ip is 123.456.789.123):
pedro@ebs-105422:~$ nc -v -w 2 123.456.789.123 3306
Connection to 123.456.789.123 3306 port [tcp/mysql] succeeded! pedro@ebs-105422:~$
Does this mean mysqld is listening on 3530?? Or is that the PID of mysqld??
pedro@ebs-105422:~$ sudo netstat -tap | grep mysql
tcp 0 0 0.0.0.0:mysql 0.0.0.0:* LISTEN 3530/mysqld
tcp6 0 0 [::]:33060 [::]:* LISTEN 3530/mysqld
pedro@ebs-105422:~$
Below is from mysql on the server, confirming port 3306
mysql> show variables where variable_name in ('hostname','port');
+---------------+------------+
| Variable_name | Value |
+---------------+------------+
| hostname | ebs-105422 |
| port | 3306 | +---------------+------------+
2 rows in set (0.01 sec)mysql>
I figured it out, this answer is just to help anyone who may have the same problem. This way is probably not so secure, with 3306 open, but a) I only have homework b) you still need the user name and password.
When you create a user on mysql it looks something like this, also when you do it via ssh on the server:
If you want remote access, you need to change the user data (or make a new user):
% here apparently represents any ip
Then on the also via ssh on the server:
find the line that has
change this to
ctrl X to quit nano nano asks if you want to save, press y, then enter to save in the same place you opened /etc/mysql/mysql.conf.d/mysqld.cnf
Then (on the server):
After that, my Python worked fine from the Idle shell: