Create new database mysql command line
To create a new database in MySQL using the command line, you can use the following command:
CREATE DATABASE database_name;
Replace database_name
with the name you want to give your new database.
For example, to create a database named mydatabase
, you would use the following command:
CREATE DATABASE mydatabase;
If you want to create a database with a specific character set and collation, you can use the following command:
CREATE DATABASE database_name CHARACTER SET charset_name COLLATE collation_name;
Replace database_name
with the name you want to give your new database, charset_name
with the character set you want to use (e.g. utf8
, latin1
, etc.), and collation_name
with the collation you want to use (e.g. utf8_general_ci
, latin1_swedish_ci
, etc.).
For example, to create a database named mydatabase
with the utf8
character set and utf8_general_ci
collation, you would use the following command:
CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;
Once you have created the database, you can use the following command to switch to it:
USE database_name;
Replace database_name
with the name of the database you just created.
For example, to switch to the mydatabase
database, you would use the following command:
USE mydatabase;
You can then create tables, insert data, and perform other database operations within the new database.