MySQL Create Database

Create Database Using mysqladmin

You would need special privileges to create or to delete a MySQL database. So assuming you have access to the root user, you can create any database using the mysql mysqladmin binary.


Here is a simple example to create a database called School −

[root@host]# mysqladmin -u root -p create SCHOOL
Enter password:******

or you can do the same on mysql>prompt

mysql> create database SCHOOL

This will generate a database SCHOOL on your MySQL server.

Python Script to Create a DataBase

MySQL .connector module has been used to generate a new database. Connect() function basically accept a certain parameter to establish a connection between MySQL and Python.


import mysql.connector
conn = mysql.connector.connect(host='localhost',user='root',password='')
cursor = conn.cursor()
cursor.execute('create database SCHOOL;')
print('database created successfully')
Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to See your article appearing on the main page and help other students/teachers.