954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

to insert russian to mysql

Hi I tried to insert russian language to mysql db but after inserting ,I am getting some strange things in database

INSERT INTO table(adtex) VALUES('1с бухгалтерия 7 Cкидка 42% на 1С:Предприятие 8 базовые версии!');

Output

adtex |
+----------------------------------------------------+
| 1? ??????????? 7 C????? 42% ?? 1?:??????????? 8 ??


Plz guide me

rahulroshan
Light Poster
27 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

What collation does your database and table use ?

pritaeas
Posting Expert
Moderator
5,484 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

You have to make sure that all components of the process of inserting your russian language strings use the same encoding. The database, tables and columns should be encoded with the utf-8 character set. Also your connection to the database - be it with the native mysql command line client, an access client like navicat or HeidiSQL, or a script language like PHP - has to set its connection character set properly. Only then the data are stored and retrieved as intended.

smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

Hi Can u plz give me an eg

Is it like this

For creating db : CREATE DATABASE confluence CHARACTER SET utf8 COLLATE utf8_bin;

for creating table : CREATE TABLE an(languagename text,languagetext VARCHAR(90) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;


For inserting into db:LOAD DATA LOCAL INFILE '~/Desktop/ru.csv' INTO TABLE an FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n';

rahulroshan
Light Poster
27 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Use the character set clause in the load data command:The character set indicated by the character_set_database system variable is used to interpret the information in the file. SET NAMES and the setting of character_set_client do not affect interpretation of input. If the contents of the input file use a character set that differs from the default, it is usually preferable to specify the character set of the file by using the CHARACTER SET clause, which is available as of MySQL 5.1.17. A character set of binary specifies “no conversion.” http://dev.mysql.com/doc/refman/5.1/en/load-data.html

smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You