Create Your First MySQL Database

MySQLMySQLBeginner
Practice Now

Introduction

Database creation is a fundamental skill for any database administrator. This challenge helps you practice creating a database in MySQL using the command line interface.

Before storing any data in MySQL, you need to create a database to organize and contain your data. A database serves as a structured container that holds tables, views, and other database objects. In this challenge, you will create a database for a bookstore application, which could later be used to store information about books, customers, and sales.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL mysql(("MySQL")) -.-> mysql/DatabaseFunctionsandDataTypesGroup(["Database Functions and Data Types"]) mysql(("MySQL")) -.-> mysql/SystemManagementToolsGroup(["System Management Tools"]) mysql(("MySQL")) -.-> mysql/BasicKeywordsandStatementsGroup(["Basic Keywords and Statements"]) mysql/BasicKeywordsandStatementsGroup -.-> mysql/use_database("Database Selection") mysql/BasicKeywordsandStatementsGroup -.-> mysql/create_database("Database Creation") mysql/DatabaseFunctionsandDataTypesGroup -.-> mysql/database("DB Function - Info Retrieval") mysql/DatabaseFunctionsandDataTypesGroup -.-> mysql/version("DB Version Check") mysql/SystemManagementToolsGroup -.-> mysql/show_status("Status Overview") subgraph Lab Skills mysql/use_database -.-> lab-418265{{"Create Your First MySQL Database"}} mysql/create_database -.-> lab-418265{{"Create Your First MySQL Database"}} mysql/database -.-> lab-418265{{"Create Your First MySQL Database"}} mysql/version -.-> lab-418265{{"Create Your First MySQL Database"}} mysql/show_status -.-> lab-418265{{"Create Your First MySQL Database"}} end

Create a Database in MySQL

In MySQL, creating a database is often the first step in setting up a new application's data storage. You'll need to connect to the MySQL server first, then use SQL commands to create and verify your database. The database name should reflect its purpose - in this case, we'll create a database named bookstore that could be used for managing a bookstore's inventory and sales data.

Tasks

  • Connect to MySQL server as root user
  • Create a new database named bookstore
  • Verify the database was created successfully

Requirements

  • All operations must be performed in the terminal within the ~/project directory
  • Use the MySQL command line client to complete database operations
  • The database name must be exactly bookstore (case sensitive)
  • You must connect as the root user without a password in this lab environment

Example

After successfully completing the tasks, when listing databases you should see output including your new database:

+--------------------+
| Database           |
+--------------------+
| bookstore          |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
โœจ Check Solution and Practice

Summary

In this challenge, you practiced creating a new database in MySQL. Creating databases is one of the most basic and essential tasks in database administration, serving as the foundation for storing and organizing data. The skills you learned - connecting to MySQL, creating a database, and verifying its existence - will be used frequently as you work with databases.