how to create database in MySQL

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

  1. Launch the MySQL workbench on your laptop/PC if you already installed or download and install it if you don’t have MySQL workbench.
  2. Click on the ‘Create a new schema in the connected server’ icon.Create a new schema in the connected server
  3. Give a name to the schema and click on Apply.name to the schema and click on Apply
  4. In the Apply SQL Script to Database window, click Apply to run the SQL command that makes the database/schema.click Apply to run the SQL command
  5. Click Finish. You can see the new schema, which has no tables, listed in the left-hand pane.Click Finish

How to create MySQL database on Linux via command line

  1. Make sure you have installed MySQL.
  2. Login to the MySQL server from the command line using the following command:login to mysql
  3. Now you are at MySQL prompt. To create a database with the name muchtech type the following command.create databse
  4. 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.create databse if not exists

By Sameer

I'm Sameer Bille, a blogger from Mumbai, India. I started MuchTech as a passion.Here at Much Tech I write about Tech Tips,Tricks and how to guide.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.