How to Create Database in MySQL
In this tutorials we will learn ,How to Create Database in MySQL Server ,Let understand what is database and a need of database.
Keep records in an organized form ,Database has object like tables ,trigger, procedure etc. The table store information in form of row, column and indexs to find the information fast.Database is responsilble for keep all the infomation in form of tables and we can access and manage the record through the MySQL database easily.
MySQL Create Database Command
CREATE DATABASE [IF NOT EXISTS] database_name
[CHARACTER SET charset_name]
In this syntax ,give the name of database which you want to create after the CREATE DATABASE (it is reserve word or keyword of SQL lanuage ),while creating database on MySQL Server ,We need to follow few rule.
1. The database name must be unique within a MySQL server instance,if you try to create database with same name then mysql server gives you the an error.
2. [IF NOT EXISTS] is optional ,if you use [IF NOT EXISTS] with create database command then only create database if it doesnot exist.
3. CHARACTER SET and COLLATE clauses is optional ,if not giving CHARACTER SET and COLLATE clauses then mysql create database with default CHARACTER SET and COLLATE .
MySQL server uses the latin1 as the default character set. Therefore, the default collation is latin1_swedish_ci . You can change these settings at mysql server startup. If you specify one character set at server startup, MySQL will use the default collation of that character set.
Creating a database using the mysql client tool orMySQL command prompt
To create database in MySQL server from mysql client tool or command prompt. Let us understand the step.
Required login having CREATE DATABASE right or permission or privilege otherwise login and root have all right.
mysql -u root -p
After above command the screen ask for password type root password .
This prompt shows that the client is connected with mysql server and ready for the command.