How to create a database in mysql and how to list existing databases?
Difficulty: 2/10
CREATE DATABASE, SHOW DATABASES, MySQL permissions
The CREATE DATABASE statement is a DDL (Data Definition Language) statement used to create a new database in MySQL RDBMS.
Statement to create database:
Statement to list databases:
Scenario Questions
0-2 years experience
1We need a fresh database for a prototype service. Walk me through the exact MySQL commands you’d run to create it and then verify it exists.
2If you try to create a database that already exists, what does MySQL return and how would you handle that in a script?
2-5 years experience
1You’re writing a deployment script that creates a new schema for each microservice. How would you structure the script to create the database, handle possible permission errors, and list all databases to confirm the new one appears?
2During a CI run, the step that lists databases returns an empty set even though you just created one. What are the possible reasons and how would you debug it?
5-8 years experience
1Our SaaS platform provisions a separate MySQL database per customer. Describe how you’d design the provisioning flow, including naming conventions, privilege isolation, and a reliable way to verify the database was created across a replicated cluster.
2When scaling to thousands of tenant databases, what operational concerns arise around SHOW DATABASES performance and how would you mitigate them?
8+ years experience
1We’re planning a migration from a single shared database to per‑tenant databases. Outline the architectural steps, governance policies, and tooling you’d put in place to ensure consistent creation, listing, and backup of databases across multiple teams.
2How would you design a cross‑team policy for database creation that balances developer autonomy with security and compliance, especially regarding who can run CREATE DATABASE and view the list of schemas?
Follow-up Questions
What would you see if you ran SHOW DATABASES without any privileges?
How do you verify that a newly created database uses the expected character set?
Can you explain how MySQL stores the list of databases internally?
Sharethis question
Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.