TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL CREATE DATABASE Statement

Overview

In this tutorial, we will create a new MySQL database on Windows operating system. We can use the CREATE DATABASE statement to create a new database. A MySQL database is represented as a directory under the data directory.

Syntax

The general syntax for the CREATE DATABASE statement is as follows:

CREATE DATABASE [IF NOT EXISTS] <database_name>
[[DEFAULT] CHARACTER SET <character_ set_name>]
[[DEFAULT] COLLATE <collation_name>]

The CHARACTER SET specifies the default character set to use and the COLLATE clause selects default collation for the ordering.

Example

To use and store database, we need to create it. A database allows us to store application data in the form of tables. It acts like a back-end data store to the application.

CREATE DATABASE `world` DEFAULT CHARACTER SET utf8mb4;

New MySQL Database

In this example, we will create a sample database called: testdb

Using MySQL Workbench

Steps to create the database.

Launch MySQL Workbench tool. In the SQL Editor tab type the following command:

CREATE DATABASE testdb;

Click on the Execute button to execute the SQL query.

 

Create Database MySQL Windows10

Issue the following command to check the database.

show databases;

The newly created database should be listed in the query output.

Show databases MySQL Win10

Using MySQL Client

Launch command prompt. Type the following command. To run mysql command from anywhere in the command prompt, we need to add the MySQL bin folder to the PATH variable.

\> mysql -u root -p

Enter the root password.

In the mysql prompt, enter the command.

mysql> CREATE DATABASE testdb;
Query OK, 1 row affected (0.21 sec)

 

Create Database from command prompt Win10

 

That’s it. We have successfully created a new MySQL Database. We can check and verify that the database is created using the SHOW DATABASES command.

 

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL:

https://www.mysql.com/

Related Posts

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

Windows 11 Services Run Prompt

MySQL /

Start MySQL Server on Windows 11

MySQL Community Downloads TDocs

MySQL /

Download & Install MySQL on Windows 11

‹ Different MySQL Components› MySQL Monitor Modes

Recent Posts

  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Print Triangle Pattern Flowchart
  • RAPTOR Editions
  • Flowgorithm Conditional Breakpoint Statement
  • Flowgorithm Read Numbers from File Example
  • Search Text File Flowchart Example
  • Flowgorithm Turtle Graphics Symbols
  • Draw Circle using Flowgorithm Turtle

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version