简体   繁体   中英

Access to Virtual machine MySQL database from windows host with python

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 this tutorial LAMP on it. I also followed this tutorial to install phpMyAdmin. Apparently, everything is working fine. I can access to phpMyAdmin from the web browser on my host machine.

The network of the virtual machine is configured as bridge adapter.

The problem is that I cannot connect when using python (also from host machine). This is the code I'm using:

import mysql.connector

cnx = mysql.connector.connect(user='root', password='XXXXX',
                              host='192.168.1.138',
                              port=3306,
                              database='mysql')
cnx.close()

The code returns this error:

DatabaseError: 1130: Host 'desktop-p7v30jj.home' is not allowed to connect to this MySQL server

I looked for information and found that it could be due to the bind-address. So I edited the file /etc/mysql/mysql.cnf and included the following two lines at the end with no success:

[mysqld]
bind-address = 0.0.0.0

What else should I try? Any idea?

Thanks in advance!

I managed to find the solution by simply creating another user, as stated in this topic: Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server

Sorry for answering.

Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM