Programming/MySQL/Databases: Difference between revisions
< Programming | MySQL
Jump to navigation
Jump to search
Brodriguez (talk | contribs) (Import from original mysql page) |
Brodriguez (talk | contribs) m (Brodriguez moved page MySQL/Databases to Programming/MySQL/Databases) |
Revision as of 00:30, 3 November 2020
Databases
MySQL splits things up into individual "databases". Generally speaking, each database is a cohesive, separate project.
Creating a New Database
From the MySQL Shell:
CREATE DATABASE <database_name>;
- Where
<database_name>
is replaced by the desired name for the database. Must be unique from all other existing databases in the MySQL server.
To specify the database character set:
CREATE DATABASE <database_name> DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;
Note that utf8mb4
is the preferred character set for most situations. See this link for details.
Loading a Database
From the MySQL Shell:
USE <database_name>;
- Where
<database_name>
is replaced by the name of database you wish to select/load. - Note that only one database can be selected/loaded at a time.
Deleting a Database
From the MySQL Shell:
DROP DATABASE <database_name>;
- Where
<database_name>
is replaced by the name of the database to delete. Note that this action cannot be undone.