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

    Stellar Converter for Database Tool

    MySQL /

    Stellar Converter for Database

    Stellar MySQL Log Analyzer

    MySQL /

    Stellar Log Analyzer for MySQL

    Stellar Repair for MySQL

    MySQL /

    Stellar Repair for MySQL

    MySQL /

    How to secure your SQL Database: Tips and Tricks

    Stellar Converter for Database

    MySQL /

    Database Converter Tools

    ‹ Different MySQL Components› MySQL Monitor Modes

    Recent Posts

    • ChatGPT Subscription Plans
    • Stellar Converter for Database
    • Stellar Log Analyzer for MySQL
    • Stellar Repair for MySQL
    • ChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI Features
    • Shaping the Future of Development: Exploring Key Trends in Software Engineering
    • Improving Java Performance with Multithreading
    • Open-source Vector Databases

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com