[Tutor] Connecting to a new mysql database
arthomas152 at comcast.net
arthomas152 at comcast.net
Sun Jul 4 16:42:26 EDT 2021
This works:
import mysql.connector
mydb = mysql.connector.connect(
host='localhost',
user='root',
password='xxxxxxxxxxxxxxx',
database='sakila')
mycursor = mydb.cursor()
mycursor.execute("Show tables;")
myresult = mycursor.fetchall()
for x in myresult:
print(x)
mydb.close()
But, when I try to open a new mysql database, I receive the message "unknown
database." Mysql reads the database without a problem. Do I need to register
my database somehow?
Windows 10, Python 3.9, and MySQL 8.0. The software for both are up to date.
I am stymied. Thanks for any help you can give me.
Arthur Thomas
Hold a book in your hand and you're a pilgrim at the gates of a new city.
Elizabeth Langer
More information about the Tutor
mailing list