title: How to connect to MySQL server on another host?
body: <p>Django can simply connect to its own MySQL server by setting <code>HOST</code> and <code>PORT</code> in <code>settings.py</code> as '' (empty string):</p>
  
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
          'NAME': 'dbname',                   # Or path to database file if using sqlite3.
          'USER': 'root',                      # Not used with sqlite3.
          'PASSWORD': 'root',                  # Not used with sqlite3.
          'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
          'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
      }
  }
  </code></pre>
  
  <p>My question is how to make it able to connect another database on another host? Suppose my machine is <code>192.168.1.33</code> and another machine to be connected is <code>192.168.1.34</code>, both are on the same network. I've tried to set this as:</p>
  
  <pre><code>'HOST': '192.168.1.34',
  'PORT': '3306',
  </code></pre>
  
  <p>and</p>
  
  <pre><code>'HOST': '192.168.1.34',
  'PORT': '',
  </code></pre>
  
  <p>but both caused this <code>OperationalError</code>:</p>
  
  <pre><code>(2003, "Can't connect to MySQL server on '192.168.1.34'(10061)")
  </code></pre>
  
  <p>SOLUTION: credit @cdhowie</p>
  
  <ol>
  <li><p>Config bind-address to the host you want in <code>/etc/mysql/my.cnf</code></p></li>
  <li><p>Create a new user for the host you want to give an access (if you don't have one).</p></li>
  <li><p>Check privileges for that user (if access denied).</p></li>
  </ol>