Answer the question
In order to leave comments, you need to log in
How to connect to mysql on Vagrant from a remote server?
I want to connect to Vagrant mysql from a Python application
@app.route('/api', methods=['GET', 'POST'])
def main():
if request.method == 'GET':
db = pymysql.connect("188.168.61.34:3306", "root", "", "dejavu")
cursor = db.cursor()
cursor.execute("SELECT VERSION()")
data = cursor.fetchone()
print("Database version : %s " % data)
db.close()
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '192.168.56.1:3306' ([Errno -2] Name or service not known)")
sudo apt-get update sudo apt-get install build-essential zlib1g-dev git-core sqlite3 libsqlite3-dev sudo aptitude install mysql-server mysql-client
sudo nano /etc/mysql/my.cnf change: bind-address = 0.0.0.0
mysql -u root -p
use mysql GRANT ALL PRIVILEGES ON . to [email protected]'%' WITH GRANT OPTION; FLUSH PRIVILEGES; exit
sudo /etc/init.d/mysql restart
Answer the question
In order to leave comments, you need to log in
1) Maybe something is messed up with the network.
Check the private network and virtual machine address match.
2) Or MySQL did not start on the virtual machine. Log into the console and check that MySQL is running.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question