开发者

How to set the locale for mysql?

I need to do language translation from English to arabic.

So i need to set the locale for mysql database table. I am creating a table in mysql like

  CREATE TABLE userinfo (
  id int(45) NOT NULL AUTO_INCREMENT,
  user_sex int(4) DEFAULT NULL,
  user_date_of_birth date DEFAULT NULL,
  user_city varchar(256) DEFAULT NULL,
  user_hometown varchar(256) DEFAULT NULL,
  PRIMARY KEY (user_basic_info_id),
  FOREIGN KEY (user_id) REFERENCES user (user_id) ON DELETE NO ACTION ON UPDATE NO ACTION
  );
开发者_如何学C

I need to add the locale for the mysql table above for arabic. I referred this but I am not able to implement it. How to to do this. Please explain me. I need guidance.


As mentioned in my answer on your related question, you need to issue the following commands on an existing DB/table to it to accept UTF-8:

ALTER DATABASE db_name DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

When creating new DB/tables, use CHARACTER SET utf8 COLLATE utf8_general_ci in CREATE statement as well.


ALTER TABLE mytable  CHARSET=cp1256 COLLATE=cp1256_general_ci;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜