Setting up a new UTF8 MySQL Database
Setting up a new UTF8 MySQL Database


Create a UTF8 database:

> CREATE DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

Create a user for the database:

> CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'user_pass';

Grant all privileges to the user:

> GRANT ALL PRIVILEGES ON *.* TO 'user_name'@'localhost' WITH GRANT OPTION;
> FLUSH PRIVILEGES;

You should probably not give him all privileges on all databases, but you can change that as needed.

If for some reason the IDENTIFIED BY clause did not work (you probably uses % instead of localhost), then do the following to fix that users password.

$ mysql -u root -p
> use mysql;
> UPDATE user SET Password = PASSWORD('new_pass') WHERE User = 'user_name';

Thats it. Enjoy…