0

I'm using an Azure Virtual Machine with ubuntu server.

I ssh into the machine and installed a lamp server (and also phpmyadmin, so i can view via browser my databases and execute operations). My django project is running on my macbook.

I tried to connect to the mysql database installed on the VM in django using the method explained both in documentation and other stackoverflow questions, but none of them are working.

Let's say 1.2.3.4 is my VM IP.

settings.py

DATABASES = {
    # mysql
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'DBname',
        'USER': 'rootuser',
        'PASSWORD': 'rootPassword',
        'HOST': '1.2.3.4',
    },
}

Output of python manage.py runserver:

django.db.utils.OperationalError:
  (2003, "Can't connect to MySQL server on '1.2.3.4' (timed out)")

Do I need to configure the mysql database? Isn't 1.2.3.4 the same IP that I need to use for the db connection?

Also when I try to install mysqlclient with pip install mysqlclient it raises an error:

Command "python setup.py egg_info" failed with error code 1
  in /private/var/folders/st/8qzvdtwx6xsc1w1ffqd2c7br0000gn/T/pip-install-p25gukfh/mysqlclient/
Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
DamienzOnly
  • 88
  • 1
  • 10

1 Answers1

0

I'm a bit rusty on mysql connections, but as stated in this answer:

What is disabled by default is remote root access. If you want to enable that, run this SQL [...]

Maybe you can check that first to rule out this kind of misconfig. Or try a different user that is not root.

Ralf
  • 16,086
  • 4
  • 44
  • 68