I am looking to a create a MySQL database from within Python. I can find instructions for how to connect to an existing database, but not how to initialize a new one.
For example, when i run the line
import MySQLdb
db = MySQLdb.connect(host="localhost", user="john", passwd="megajonhy", db="jonhydb") (presumably because connecting will not create a database if it doesn't already exist, as i had hoped)
Which is the first line of instructions on How do I connect to a MySQL Database in Python? I get the error _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
How do i go about initializing a new MySQL database to work with?
MySQL Community Serverfrom mysql.com that the above code should work to create the database?jonhydbalready created therein. You might want to consider installing the MySQL Workbench too to help you set up your database and tables