Program to create a database with Mysql.

Here, we have a basic program example to create database using Mysql in Python and Java.

Code to create database in Python language

import mysql.connector
con=mysql.connector.connect(host="localhost", user="root", passwd="root")
cur=con.cursor()
cur.execute("create database coder")
con.close()

Code to create database in Java language

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class CreateDB {
   public static void main(String[] args) {
      Connection con=null;
      Statement stmt=null;
      String yourDatabaseName="Customer_Tracker_Database";
      try {
         con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test3?useSSL=false",
         "root","vsit@123");
         stmt = con.createStatement();
         int status = stmt.executeUpdate("CREATE DATABASE : "+yourDatabaseName);
         if(status > 0) {
            System.out.println("Database is created successfully !!!");
         }
      }
      catch(Exception e) {
         e.printStackTrace();
      }
   }
}