Python Tutorials · Python MySQL

MySQL Create Database

Learn all about MySQL Create Database in this comprehensive tutorial.

5 min read advanced
  • To create a database in MySQL, use the "CREATE DATABASE" statement:
  • You can check if a database exist by listing all databases in your system by using the "SHOW DATABASES" statement:

Creating a Database

To create a database in MySQL, use the "CREATE DATABASE" statement:

python

If the above code was executed with no errors, you have successfully created a database.

Check if Database Exists

You can check if a database exist by listing all databases in your system by using the "SHOW DATABASES" statement:

python

Or you can try to access the database when making the connection:

python

If the database does not exist, you will get an error.

Module quiz

2 questions
1

Which of the following is true about MySQL Create Database?

2

What is the most common pitfall when working with MySQL Create Database?

Answer all questions to submit.