xxxxxxxxxx
The command mysql -u root -p is used to connect to the MySQL shell
with parameters -u and -p. The -u parameter specifies the MySQL user name,
in this case, it is the root user. The -p parameter is used to specify the password
to use when connecting to the server.
If the password is not given, it is asked from the tty
xxxxxxxxxx
import mysql.connector
# Connect to the MySQL database using the root user
connection = mysql.connector.connect(
host="localhost",
user="root",
password="your_password",
database="your_database"
)
# ... Perform database operations
# Close the connection when done
connection.close()