I am hosting my website on PythonAnywhere.
I have two databases on the service: myusername$production and myusername$dev.
The production db backs itself up every night and loads the dev database with the most recent batch of live data. I am trying to connect my Django development environment to the dev database through ssh, which is possible as a paying PythonAnywhere customer.
I followed their advice and downloaded MySQL Workbench, which connects to said database without any issues. I then tried to set up my dev.py settings in Django as follows:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myusername$dev',
'USER': 'myusername',
'PASSWORD': 'mypassword',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
However this results in a django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' (10061)") error. I also tried replacing 127.0.0.1 with localhost, as well as leaving both host and port blank, but neither of these worked.
I then tried the other two options on their website, aka accessing the db directly through python code, as well as using Putty (I'm a windows 10 user) however non of these worked.
Any advice would be greatly appreciated.
127.0.0.1assumes the database is on your PC. So that cannot be ruight. So use the IP address of yor server insteadmyusername.mysql.pythonanywhere-services.comso I tried using that. It took a bit longer than when I was using localhost but it still failed.... Error10060this time though! Progress I guess?myusernamehave rights to signin remotely