budhajeewa
budhajeewa

Reputation: 2408

Creating a MySQL Database with a Specific Character Set and Collation

When creating a MySQL database with CREATE SCHEMA, it uses MySQL's default character set and collation. But I want to change that.

How do I create a MySQL Database with a specific character set and collation?

Upvotes: 1

Views: 3361

Answers (2)

Rahul Tripathi
Rahul Tripathi

Reputation: 172438

You can try like this:

CREATE DATABASE IF NOT EXISTS someDatabase
 DEFAULT CHARACTER SET = 'utf8' DEFAULT COLLATE 'utf8_general_ci'

and if the database is already created, then you can alter is like this:

ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Upvotes: 5

budhajeewa
budhajeewa

Reputation: 2408

CREATE SCHEMA `my_database`
DEFAULT CHARACTER SET utf8
COLLATE utf8_unicode_ci ;

Upvotes: 0

Related Questions