Last updated on July 2nd, 2022 at 11:00 am
MySQL is an open-source relational database management system (RDBMS) developed by Oracle that is based on structured query language (SQL). MySQL stores data in table formats which are made from rows and columns. You can manipulate MySQL data using SQL. Using SQL you can retrieve, update, create or delete data and databases and do other data-related operations to data. Here I am writing about how to create database in MySQL.
How To Create Database In MySQL
If you have MySQL installed on your laptop/PC or server. Then you can easily create a database using MySQL.
MySQL Create Database Syntax
‘Create Database’ SQL statement is used to create a database. Like other RDBMS in MySQL create database statement is used to create a new database. Using create database statement you can create a database with the specified name.
Create Database yourdatabasename;
If sometimes a database is already created with a specified name then you will get an error if the database already exists. So it’s better to use the IF NOT EXISTS clause to avoid an error.
CREATE DATABASE IF NOT EXISTS yourdatabasename;
Once you execute the above statement MySQL will give you a message whether the database has been created successfully or not.
How to create database in MySQL Workbench
- Launch the MySQL workbench on your laptop/PC if you already installed or download and install it if you don’t have MySQL workbench.
- Click on the ‘Create a new schema in the connected server’ icon.
- Give a name to the schema and click on Apply.
- In the Apply SQL Script to Database window, click Apply to run the SQL command that makes the database/schema.
- Click Finish. You can see the new schema, which has no tables, listed in the left-hand pane.
How to create MySQL database on Linux via command line
- Make sure you have installed MySQL.
- Login to the MySQL server from the command line using the following command:
- Now you are at MySQL prompt. To create a database with the name muchtech type the following command.
- If a database of the same name already exists, you will get an error saying that the database already exists. To avoid this error use the following command.