我正在尝试在pythonanywhere上部署一个django项目,但它给出了错误 -
(2003, "Can't connect to MySQL server on 'mysql.server' (111)")
我已经看到许多问题已经被问到这个问题,但没有答案解决了我的问题。可能存在访问数据库的previlleges问题。
数据库设置是 -
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mutechrobotics$mutech_db', 'USER': 'mutechrobotics', 'PASSWORD':'root', 'HOST': 'mysql.server', } }
在运行show grants命令后显示数据库(实际上我只需要一个数据库,但我无法删除额外的数据库)
mysql> show grants ;
+-------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for mutechrobotics@% |
+-------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'mutechrobotics'@'%' IDENTIFIED BY PASSWORD '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' WITH MAX_USER_CONNECTIONS 3 |
| GRANT ALL PRIVILEGES ON `mutechrobotics$default`.* TO 'mutechrobotics'@'%' |
| GRANT ALL PRIVILEGES ON `mutechrobotics$mutechnew_db`.* TO 'mutechrobotics'@'%' |
| GRANT ALL PRIVILEGES ON `mutechrobotics$mutech_db`.* TO 'mutechrobotics'@'%' |
| GRANT ALL PRIVILEGES ON `mutechrobotics$mu_db`.* TO 'mutechrobotics'@'%' |
+-------------------------------------------------------------------------------------------------------------------------------------------+
5 rows in set (0.00 sec)
my.cnf文件是 -
[client] password = "root"
当我尝试将所有优先权交给用户 - “mutechrobotics”时,我收到以下错误 -
mysql> GRANT ALL PRIVILEGES ON *.* TO 'mutechrobotics'@'%'
IDENTIFIED BY PASSWORD 'root';
ERROR 1045 (28000): Access denied for
user 'mutechrobotics'@'%' (using password: YES)
尝试以root身份登录时,我收到错误 -
mysql> mysql -u root -p ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql
-u root -p' at line 1
有人请帮我解决这个问题。
答案 0 :(得分:4)
不推荐使用mysql.server
作为主机名。根据官方PythonAnywhere Django tutorial,您现在应该使用:
'HOST': 'username.mysql.pythonanywhere-services.com',