I've created a Database through the website page. If click on it i get redirected to the MySQL console and everything works. I'm also able to access it from my local machine by following this tutorial: https://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere/.
Now I want to connect it to a Django webapp, but when I use the same code I get
MySQLdb.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
I added this to the settings.py hoping it would help, but nothing changed
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'NicolaMarchioro$SampleDatabase',
'USER': 'NicolaMarchioro',
'PASSWORD': '******',
'HOST': '127.0.0.1',
'PORT':'3306'
}
}
The same error is thrown if i try to access the Database from a console (or ssh connection) using
mysql -u NicolaMarchioro -p
or any mysql command for that matter