xxxxxxxxxx
import mysql.connector
# Connect to the MySQL database
cnx = mysql.connector.connect(user='your_username', password='your_password', host='localhost', database='your_database')
cursor = cnx.cursor()
# Execute a query to retrieve the MySQL version
cursor.execute("SELECT VERSION();")
# Fetch the result
version = cursor.fetchone()[0]
# Print the MySQL version
print("MySQL version:", version)
# Close the cursor and connection
cursor.close()
cnx.close()