How to create a MySQL database with default encoding and collation

Hi there, pretty much time since my last post (and I ‘ll apologise in a future post)!

During the project that I was exposed to, to the company I work for, the last months’ google searches resulted finding myself with the difficulty to reach a solution for creating a database with default encoding/character set and collation, so I decided to write this post, when finding some free time.

Assuming that we want to create a MySQL database from command line, with default encoding and collation, the command should look something like this, in a generic format:

CREATE DATABASE [preferred_database_name] DEFAULT CHARACTER SET [preferred_encoding] DEFAULT COLLATE [preferred_collation];

More specifically, if I would like to create a database named test_db, with the default encoding of utf8 and default collation of utf8_general_ci, the generic format, easily converts into:

CREATE DATABASE test_db DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;

Pretty easy, huh?! Have a nice week!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s