Managing Databases in MySQL
MySQL·3 min read·Jan 1, 2025
In MySQL, the data is organized and stored in tables, which are themselves stored in databases.
Each MySQL server can hold and manage several independent databases, which ultimately allows it to store and manage different sets of data separately.
This separation offers the possibility to grant specific permissions on a per-database basis, allowing for better control over who can access, modify, or delete data within each database.
Creating a database
To create a new database, you can use the CREATE DATABASE keywords followed by the name of the database:
CREATE DATABASE database_name;Upon execution, MySQL will either output this message confirming the creation of the specified database:
Query OK, 1 row affected (0.01 sec)Or this error message if it already exists:
ERROR 1007 (HY000): Can't create database 'database_name'; database existsNote: Since database names are case-sensitive, it is recommended to keep them concise and write them using the snake case syntax, for example:
streamingore_learning.
Example
This SQL statement will create a new database named learnbackend:
mysql> CREATE DATABASE learnbackend;Unlock the Build RESTful APIs in Node.js module
Learn how to build real database-backed and framework-powered RESTful APIs with MySQL, Sequelize, and Express.
You get immediate access to:
- 37 focused lessons across MySQL, Sequelize, backend, and Express
- 4 real-world projects with commented solutions
- Ongoing updates to this bundle
- Lifetime access to this bundle