1. Create a database
Create DATABASE name
eg
Create Database
To view the data you have created:
show databases;
Results:
2. The database name corresponding to the database does not exist in the case of the creation. If it already exists, it is not created.
Create DB if not EXISTS database name
eg
Create DATABASE if not exists
Results:
Delete the first process data first:
Drop DATABASE MyDatabase;
See if the deletion succeeds:
show databases;
Results:
And then come back again:
Create DATABASE if not exists
See if the creation is successful:
show databases;
3. Modify the encoding of an existing library:
ALTER DATABASE name character Set UTF8
eg
ALTER DATABASE MyDatabase character set UTF8;
4. Specify the encoding in the new database:
Create DB if not EXISTS database name default CharSet = UTF8;
MySQL creates a data database to avoid a new library name already exists