How to Create and Drop Database in MySQL

Channel: Linux
Abstract: Using mysqladmin command we can create database from Linux shell or windows command line. . This is useful for running query from shell or bash script

MySQL is the most popular database for web development. After installing mysql on our system. Let’s start with the database creation.. In this article we will describe you to How to create and drop database in MySQL server.

1. Create Database from MySQL Prompt:

To create database from mysql command prompt, first login to your mysql server using administrative privileges.

# mysql -u root -p

mysql> CREATE DATABASE exampledb;

You can also set the default character set to utf8 by defining with command as below.

mysql> CREATE DATABASE exampledb DEFAULT CHARACTER SET utf8;
2. Create Database from System Command Prompt:

Using mysqladmin command we can create database from Linux shell or windows command line. . This is useful for running query from shell or bash scripts for automation tasks.

# mysqladmin -u root -p create exampledb
3. Drop Database from MySQL Prompt:

To drop database from mysql command prompt, first login to your mysql server using administrative privileges.

# mysql -u root -p

mysql> DROP DATABASE exampledb;
4. Drop Database from System Command Prompt:

Using mysqladmin command we can also drop any database from Linux shell or windows command line. This is useful for running query from shell scripts.

# mysqladmin -u root -p drop exampledb

Ref From: tecadmin

Related articles