Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(2003, "Can't connect to MySQL server on 'mysql.server' (111)") error in pythonanywhere

I am trying to deploy a django project on pythonanywhere but it is giving error-

(2003, "Can't connect to MySQL server on 'mysql.server' (111)")

I have seen many questions already asked for this problem but no answer solves my problem. May be there is a previlleges problem with accessing the database .

Database settings are-

DATABASES = {    'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'mutechrobotics$mutech_db',
    'USER': 'mutechrobotics',
    'PASSWORD':'root',
    'HOST': 'mysql.server',
} }

On running show grants command following databases are displaying(Actually i only need one database out of them but i am unable to drop the extra ones)

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"

When i try to give all previleges to user- "mutechrobotics" then i am getting the following error-

mysql> GRANT ALL PRIVILEGES ON *.* TO 'mutechrobotics'@'%'
 IDENTIFIED BY PASSWORD 'root';


ERROR 1045 (28000): Access denied for
     user 'mutechrobotics'@'%' (using password: YES)

While trying to login as a root i am getting the error as-

 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

Somebody please help me sort out this problem.

like image 548
Rahul Satal Avatar asked Apr 22 '16 00:04

Rahul Satal


1 Answers

Using mysql.server as the hostname is deprecated. According to the official PythonAnywhere Django tutorial, you should now use:

'HOST': 'username.mysql.pythonanywhere-services.com',
like image 156
Selcuk Avatar answered Sep 24 '22 23:09

Selcuk