(2003, "Can't connect to MySQL server on 'mysql.server' (111)") pythonanywhere 错误
(2003, "Can't connect to MySQL server on 'mysql.server' (111)") error in pythonanywhere
我正在尝试在 pythonanywhere 上部署一个 Django 项目,但出现错误-
(2003, "Can't connect to MySQL server on 'mysql.server' (111)")
我已经看到很多关于这个问题的问题,但没有答案能解决我的问题。可能是访问数据库时出现问题。
Database settings are-
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 file is-
[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
谁能帮我解决这个问题。
不推荐使用 mysql.server
作为主机名。根据官方PythonAnywhere Django tutorial,你现在应该使用:
'HOST': 'username.mysql.pythonanywhere-services.com',
我正在尝试在 pythonanywhere 上部署一个 Django 项目,但出现错误-
(2003, "Can't connect to MySQL server on 'mysql.server' (111)")
我已经看到很多关于这个问题的问题,但没有答案能解决我的问题。可能是访问数据库时出现问题。
Database settings are-
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 file is-
[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
谁能帮我解决这个问题。
不推荐使用 mysql.server
作为主机名。根据官方PythonAnywhere Django tutorial,你现在应该使用:
'HOST': 'username.mysql.pythonanywhere-services.com',