在 python 中创建我的数据库,但我找不到它

Create my database in python but i can't find it

我用 python

创建我的数据库
    import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="root",
  password="126332"
)

mycursor = mydb.cursor()

mycursor.execute("CREATE DATABASE mydatabase")

但是在 goto cmd 和 mysql 8.0 命令行和 运行 这个命令之后

mysql> SHOW DATABASEs;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| payroll            |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.28 sec)

但我看不到我的数据库“mydatabase”

它在哪里?

当转到我的代码并运行这段代码时,我看到了我的数据库

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="root",
  password="126332"
)

mycursor = mydb.cursor()

mycursor.execute("SHOW DATABASES")

for x in mycursor:
  print(x)

结果:

('information_schema',)
('mydatabase',)
('performance_schema',)
('sys',)
('systems',)
    import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword"
)

mycursor = mydb.cursor()

#检查数据库列表:

    import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword"
)

mycursor = mydb.cursor()

mycursor.execute("SHOW DATABASES")

for x in mycursor:
  print(x) 

mycursor.execute("CREATE DATABASE mydatabase")