How to create databases in MySQL: Three straightforward ways


Creating a database is a basic task in MySQL, but there are multiple ways to do it. This post covers three clear methods, whether you prefer SQL queries, command-line tools, or visual interfaces.
Ways to Create MySQL Databases:
1. SQL Statements in a Client or Script
You can create a database using a direct SQL command:
Avoid conflicts with:
CREATE DATABASE IF NOT EXISTS project;
Need to control character sets?
CREATE DATABASE IF NOT EXISTS project
CHARACTER SET utf8mb4
COLLATE utf8mb4_general_ci;
2. Terminal with the MySQL CLI
From your terminal:
mysql -u root -p
Then:
CREATE DATABASE project;
Use SHOW DATABASES;
to confirm. Ideal for managing servers or automating setups.
3. GUI-Based Tools (e.g., DbVisualizer)
For those who prefer point-and-click workflows:
Connect to your MySQL server.
Right-click the “Databases” section.
Select “Create Database…”
Enter a name and execute.
No SQL typing needed—this is helpful for rapid dev environments or onboarding new team members.
FAQ
What’s the benefit of IF NOT EXISTS
?
Prevents duplication errors if the database already exists.
Do I need special privileges to create a database?
Yes, the CREATE
privilege is required.
Schema vs. Database—what’s the difference?
In MySQL, both terms mean the same thing.
What about tools like MySQL Workbench?
You can create databases there using the “Create Schema” option—it works the same way.
Conclusion
Creating a database is often the first step in structuring an application’s data layer. Whether you're using SQL queries, the MySQL CLI, or a GUI client, each method is valid and useful in different contexts. SQL gives you precise control. The command line helps with quick admin tasks, and graphical tools simplify the process for non-technical users or when working fast.
For more guidance, real-world context, and advanced usage, check out the MySQL CREATE DATABASE Statement: Definitive Guide.
Subscribe to my newsletter
Read articles from DbVisualizer directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

DbVisualizer
DbVisualizer
DbVisualizer is the database client with the highest user satisfaction. It is used for development, analytics, maintenance, and more, by database professionals all over the world. It connects to all popular databases and runs on Win, macOS & Linux.