MySQL Create data database to avoid new library name already exists

Source: Internet
Author: User
Tags mysql create

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.