Create Database

0
234

To create a database in MySQL, use the "CREATE DATABASE" statement:

Below is the example of Creating a MySQL Database in Python:

import mysql.connector mydb = mysql.connector.connect( host="localhost", user="yourusername", password="yourpassword" ) mycursor = mydb.cursor() mycursor.execute("CREATE DATABASE mydatabase")

If the above code was executed with no errors, It means your database has been successfully created.

Check if Database Exists

You can also check if a database exist before you create a database by listing all databases in your system by using the "SHOW DATABASES" statement. Below is the example:

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)
Search
Categories
Read More
Other
Europe Powder Sulfur Market Impact, Potential, Market Flow, Developments and Analysis
Executive Summary Europe Powder Sulfur Market : Data Bridge Market Research analyzes...
By Shim Carter 2025-06-23 09:35:25 0
Other
Mumbai to Nagpur Cab
Book Mumbai to Nagpur cab online at best price. CabBazar provides car rental services for all cab...
By Cab Bazar 2025-06-14 06:30:48 0
Shopping
From Clicks to Pages: The Surprising Return of Printed Catalogs in Online Retail
  In the era of click-to-cart convenience, it might seem odd to talk about printed catalogs....
By Sujit Ahir 2025-05-23 13:20:40 0
Other
Vellore to Yelagiri Cab
Book Vellore to Yelagiri cab online at best price. CabBazar provides car rental services for all...
By Cab Bazar 2025-06-23 06:58:10 0
Other
Strengthening Recovery: Hernia Repair Devices Market Across 10 Major Countries
"Executive Summary (U.S., Canada, U.K., Germany, Italy, France, Spain, Japan, India, China,...
By Dbmrraaj Sinha 2025-06-27 08:57:24 0
Omaada - A global social and professionals networking platform https://www.omaada.com