How to insert Hindi language in Mysql

2019-01-12 04:01发布

I changed the charset set but does not work

CREATE TABLE `tbl_hindi` (
  `data` varchar(1000) character set utf8 collate utf8_bin default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `tbl_hindi` VALUES ('कंप्यूटर');

标签: mysql hindi
7条回答
Melony?
2楼-- · 2019-01-12 04:18

The charset of the database needs to be utf8_unicode_ci.

Try creating a new database, as well as a new table.

CREATE DATABASE hindi_test
    CHARACTER SET utf8
    COLLATE utf8_unicode_ci;

USE hindi_test;

CREATE TABLE `hindi` (
    `data` varchar(200) COLLATE utf8_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT INTO `hindi` (`data`) VALUES
    ('कंप्यूटर');

This works on my install. If it doesn't work for you, something might be wrong with your server settings.

查看更多
欢心
3楼-- · 2019-01-12 04:23

from your phpmyadmin change collation of your table to utf16_general_ci... Note: it worked for me..

查看更多
Deceive 欺骗
4楼-- · 2019-01-12 04:24

If the table has already been created and the problem is about storing (your) local language characters, utf8_general_ci or utf16_general_ci would be for you: Fire following query:

ALTER TABLE 'tbl_hindi' CHANGE 'data' 'data' VARCHAR(100) CHARSET utf8 COLLATE utf16_general_ci DEFAULT '' NOT NULL;

If this too doesn't solve your problem, try altering the database collation to utf16_general_ci.

查看更多
\"骚年 ilove
5楼-- · 2019-01-12 04:32

You do not need database change, all you need is to alter table column.

ALTER TABLE `YOUR TABLE` CHANGE `data ` `data ` VARCHAR(1000) 
CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; 

This change works fine and very feasible.

查看更多
forever°为你锁心
6楼-- · 2019-01-12 04:32

Try this:

CREATE TABLE tbl_hindi (
    data nvarchar(1000),
);
INSERT INTO tbl_hindi VALUES (N'कंप्यूटर');
SELECT * FROM tbl_hindi;
查看更多
Animai°情兽
7楼-- · 2019-01-12 04:37

just use N before the value like this $sql="insert into indextbl Values('Null',N'$abc')";

查看更多
登录 后发表回答