在MySQL数据库中保存阿拉伯文数据

时间:2021-07-13 07:41:20

I have changed the charset of the tables and of the column, i get the arabic text as ???? marks in MYSQL database

我已经更改了表格和列的字符集,我得到阿拉伯语文本为????在MYSQL数据库

here is the design of the table

这是桌子的设计

  CREATE DATABASE mydb
  DEFAULT CHARACTER SET utf8
  DEFAULT COLLATE utf8_general_ci;


   CREATE TABLE `categories` (                        
   `category_id` tinyint(2) NOT NULL auto_increment,           
   `category_name` varchar(50)character set utf8 NOT NULL ,  
   PRIMARY KEY  (`category_id`) 


   insert into `mydb`.`categories` 
    (`category_id`, `category_name`)
    values (1,'کتگوری');
   commit;

When I again fire select query it shows ???? as text?

当我再次触发select查询时,它会显示???? ?作为文本吗?

Can anyone tell me where am i doing wrong?

有人能告诉我我哪里做错了吗?

5 个解决方案

#1


25  

To insert Arabic Data manually into your Phpmyadmin.

将阿拉伯数据手动插入到Phpmyadmin中。

First you check either your database , table and column name is utf8 set or not. If these are not set to utf8 then first you set it then you may insert arabic data into you db table.

首先检查数据库、表和列名是否设置为utf8。如果这些数据没有设置为utf8,那么首先要设置它,然后可以将阿拉伯数据插入到db表中。

YOU MAY CHECK EACH OF THESE BY LOOKING BELOW EXAMPLE.

For Database:

数据库:

SELECT default_character_set_name FROM information_schema.SCHEMATA S
WHERE schema_name = "schemaname";

For Tables:

表:

SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
       information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
  AND T.table_schema = "schemaname"
  AND T.table_name = "tablename";

For Columns:

列:

SELECT character_set_name FROM information_schema.`COLUMNS` C
WHERE table_schema = "schemaname"
  AND table_name = "tablename"
  AND column_name = "columnname";

You may easily set utf8 to your tables if you are using SQLYog.

如果使用SQLYog,您可以轻松地将utf8设置到表中。

Just right click on db, table, column name and click on alter option and set to

只需右键单击db、表、列名,然后单击alter选项并设置为

Database Chartset = utf8 Database Collation = utf8_general_ci .

数据库Chartset = utf8数据库排序= utf8_general_ci。

Just Enjoy ....

只是享受....

#2


17  

To read ,write and sort Arabic text in mysql database using php correctly, make sure that:

要正确使用php在mysql数据库中读取、写入和排序阿拉伯语文本,请确保:

  1. MySQL charset: UTF-8 Unicode (utf8)

    MySQL字符集:UTF-8 Unicode (utf8)

  2. MySQL connection collation: utf8_general_ci

    MySQL连接排序:utf8_general_ci

  3. your database and table collations are set to: utf8_general_ci or utf8_unicode_ci

    您的数据库和表排序集被设置为:utf8_general_ci或utf8_unicode_ci

Then, add this code in your php script when you connect to db:

然后,在连接到db时,在php脚本中添加以下代码:

mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');

For more details

为更多的细节

#3


7  

We can convert database or db table to uft8 supportive with below query:

我们可以将数据库或db表转换为uft8 support,查询如下:

ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE tablename CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE columnname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

Hope it helps !

希望它可以帮助!

Read More @

阅读更多@

https://kb.mediatemple.net/questions/138/Default+MySQL+character+set+and+collation#gs

https://kb.mediatemple.net/questions/138/Default + MySQL +品质+ +和+整理# gs

http://hollyslog.com/technology/how-to-store-arabic-or-hebrew-characters-mysql-database

http://hollyslog.com/technology/how-to-store-arabic-or-hebrew-characters-mysql-database

#4


4  

Change the database tables collations types to utf8_general_ci and also table fields collations change to utf8_general_ci.

将数据库表排序规则类型更改为utf8_general_ci,并将表字段排序规则更改为utf8_general_ci。

在MySQL数据库中保存阿拉伯文数据

#5


3  

Make sure that your client software is also using UTF-8.

确保您的客户端软件也使用UTF-8。

http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

#1


25  

To insert Arabic Data manually into your Phpmyadmin.

将阿拉伯数据手动插入到Phpmyadmin中。

First you check either your database , table and column name is utf8 set or not. If these are not set to utf8 then first you set it then you may insert arabic data into you db table.

首先检查数据库、表和列名是否设置为utf8。如果这些数据没有设置为utf8,那么首先要设置它,然后可以将阿拉伯数据插入到db表中。

YOU MAY CHECK EACH OF THESE BY LOOKING BELOW EXAMPLE.

For Database:

数据库:

SELECT default_character_set_name FROM information_schema.SCHEMATA S
WHERE schema_name = "schemaname";

For Tables:

表:

SELECT CCSA.character_set_name FROM information_schema.`TABLES` T,
       information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` CCSA
WHERE CCSA.collation_name = T.table_collation
  AND T.table_schema = "schemaname"
  AND T.table_name = "tablename";

For Columns:

列:

SELECT character_set_name FROM information_schema.`COLUMNS` C
WHERE table_schema = "schemaname"
  AND table_name = "tablename"
  AND column_name = "columnname";

You may easily set utf8 to your tables if you are using SQLYog.

如果使用SQLYog,您可以轻松地将utf8设置到表中。

Just right click on db, table, column name and click on alter option and set to

只需右键单击db、表、列名,然后单击alter选项并设置为

Database Chartset = utf8 Database Collation = utf8_general_ci .

数据库Chartset = utf8数据库排序= utf8_general_ci。

Just Enjoy ....

只是享受....

#2


17  

To read ,write and sort Arabic text in mysql database using php correctly, make sure that:

要正确使用php在mysql数据库中读取、写入和排序阿拉伯语文本,请确保:

  1. MySQL charset: UTF-8 Unicode (utf8)

    MySQL字符集:UTF-8 Unicode (utf8)

  2. MySQL connection collation: utf8_general_ci

    MySQL连接排序:utf8_general_ci

  3. your database and table collations are set to: utf8_general_ci or utf8_unicode_ci

    您的数据库和表排序集被设置为:utf8_general_ci或utf8_unicode_ci

Then, add this code in your php script when you connect to db:

然后,在连接到db时,在php脚本中添加以下代码:

mysql_query("SET NAMES 'utf8'");
mysql_query('SET CHARACTER SET utf8');

For more details

为更多的细节

#3


7  

We can convert database or db table to uft8 supportive with below query:

我们可以将数据库或db表转换为uft8 support,查询如下:

ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE tablename CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE columnname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

Hope it helps !

希望它可以帮助!

Read More @

阅读更多@

https://kb.mediatemple.net/questions/138/Default+MySQL+character+set+and+collation#gs

https://kb.mediatemple.net/questions/138/Default + MySQL +品质+ +和+整理# gs

http://hollyslog.com/technology/how-to-store-arabic-or-hebrew-characters-mysql-database

http://hollyslog.com/technology/how-to-store-arabic-or-hebrew-characters-mysql-database

#4


4  

Change the database tables collations types to utf8_general_ci and also table fields collations change to utf8_general_ci.

将数据库表排序规则类型更改为utf8_general_ci,并将表字段排序规则更改为utf8_general_ci。

在MySQL数据库中保存阿拉伯文数据

#5


3  

Make sure that your client software is also using UTF-8.

确保您的客户端软件也使用UTF-8。

http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html

http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html