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 DATABASEexampledb ;
You can also set the default character set to utf8 by defining with command as below.
mysql> CREATE DATABASEexampledb DEFAULT CHARACTER SETutf8 ;
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 createexampledb
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 DATABASEexampledb ;
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 dropexampledb