title: Access to Virtual machine MySQL database from windows host with python
body: <p>I´m trying to connect to a mysql database installed on a virtual machine with Ubuntu Server. I´m very new to server administration so I followed <a href="https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-18-04" rel="nofollow noreferrer">this tutorial</a> LAMP on it. I also followed <a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04" rel="nofollow noreferrer">this tutorial</a> to install phpMyAdmin. Apparently, everything is working fine. I can access to phpMyAdmin from the web browser on my host machine.</p>
  
  <p>The network of the virtual machine is configured as bridge adapter.</p>
  
  <p>The problem is that I cannot connect when using python (also from host machine). This is the code I'm using:</p>
  
  <pre><code>import mysql.connector
  
  cnx = mysql.connector.connect(user='root', password='XXXXX',
                                host='192.168.1.138',
                                port=3306,
                                database='mysql')
  cnx.close()
  </code></pre>
  
  <p>The code returns this error:</p>
  
  <pre><code>DatabaseError: 1130: Host 'desktop-p7v30jj.home' is not allowed to connect to this MySQL server
  </code></pre>
  
  <p>I looked for information and found that it could be due to the bind-address. So I edited the file <code>/etc/mysql/mysql.cnf</code> and included the following two lines at the end with no success:</p>
  
  <pre><code>[mysqld]
  bind-address = 0.0.0.0
  </code></pre>
  
  <p>What else should I try? Any idea?</p>
  
  <p>Thanks in advance!</p>