将阿拉伯语数据保存在 MySQL 数据库中

发布于 2024-11-27 04:07:50 字数 557 浏览 1 评论 0原文

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

是表的设计

  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;

当我再次触发选择查询时,它显示????作为文本?

谁能告诉我我哪里做错了?

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

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?

Can anyone tell me where am i doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

清旖 2024-12-04 04:07:50

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

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

您可以通过查看下面的示例来检查每一项。

对于数据库:

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

对于表:

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";

对于列:

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

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

只需右键单击数据库、表、列名称,然后单击更改选项并设置为

数据库图表集 = utf8
数据库排序规则 = utf8_general_ci 。

只是享受....

To insert Arabic Data manually into your 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.

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.

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

Database Chartset = utf8
Database Collation = utf8_general_ci .

Just Enjoy ....

ぺ禁宫浮华殁 2024-12-04 04:07:50

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

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

  2. MySQL连接排序规则:utf8_general_ci

  3. 您的数据库和表排序规则设置为: utf8_general_ciutf8_unicode_ci

然后,添加当您连接到数据库时,您的 php 脚本中的此代码:

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

了解更多详情

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

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

  2. MySQL connection collation: utf8_general_ci

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

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

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

For more details

长亭外,古道边 2024-12-04 04:07:50

我们可以使用以下查询将数据库或 db 表转换为 uft8 支持:

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

希望有帮助!

阅读更多内容@

https://kb.mediatemple。 net/questions/138/Default+MySQL+character+set+and+collat​​ion#gs

http://hollyslog.com/technology/how-to -存储阿拉伯语或希伯来语字符-mysql-数据库

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

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

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

听不够的曲调 2024-12-04 04:07:50

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

输入图像描述这里

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

enter image description here

幸福不弃 2024-12-04 04:07:50

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

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

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

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

笑红尘 2024-12-04 04:07:50

试试这个代码:

$conn = new mysqli($server,$username,$password,$dbname);
$conn->set_charset("UTF8");

Try this code :

$conn = new mysqli($server,$username,$password,$dbname);
$conn->set_charset("UTF8");
你穿错了嫁妆 2024-12-04 04:07:50
CREATE TABLE mydb.categories         
(category_id tinyint(2) NOT NULL AUTO_INCREMENT
,category_name MEDIUMTEXT NOT NULL
,PRIMARY KEY (category_id)) DEFAULT CHARACTER SET utf8
CREATE TABLE mydb.categories         
(category_id tinyint(2) NOT NULL AUTO_INCREMENT
,category_name MEDIUMTEXT NOT NULL
,PRIMARY KEY (category_id)) DEFAULT CHARACTER SET utf8
千紇 2024-12-04 04:07:50

配置配置 = new Configuration();

            // Hibernate settings equivalent to hibernate.cfg.xml  properties
            Properties settings = new Properties();
            
            settings.put(Environment.DRIVER, "com.mysql.cj.jdbc.Driver");
            settings.put(Environment.URL, "jdbc:mysql://localhost:3306/alizidan?useSSL=false&useUnicode=yes&characterEncoding=UTF-8");
            settings.put(Environment.USER, "root");
            settings.put(Environment.PASS, "");
            settings.put(Environment.DIALECT, "org.hibernate.dialect.MySQL5Dialect");
            // does not work with my sql settings.put(Environment.HBM2DDL_CHARSET_NAME, "UTF-8");

// characterEncoding=UTF-8 at "jdbc:mysql://localhost:3306/alizidan?useSSL=false&characterEncoding=UTF-8" 工作得非常好

            settings.put(Environment.SHOW_SQL, "true");

            settings.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");

    //        settings.put(Environment.HBM2DDL_AUTO, "create-drop");

            configuration.setProperties(settings);

Configuration configuration = new Configuration();

            // Hibernate settings equivalent to hibernate.cfg.xml  properties
            Properties settings = new Properties();
            
            settings.put(Environment.DRIVER, "com.mysql.cj.jdbc.Driver");
            settings.put(Environment.URL, "jdbc:mysql://localhost:3306/alizidan?useSSL=false&useUnicode=yes&characterEncoding=UTF-8");
            settings.put(Environment.USER, "root");
            settings.put(Environment.PASS, "");
            settings.put(Environment.DIALECT, "org.hibernate.dialect.MySQL5Dialect");
            // does not work with my sql settings.put(Environment.HBM2DDL_CHARSET_NAME, "UTF-8");

// characterEncoding=UTF-8 at "jdbc:mysql://localhost:3306/alizidan?useSSL=false&characterEncoding=UTF-8" work VERY GOOD

            settings.put(Environment.SHOW_SQL, "true");

            settings.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread");

    //        settings.put(Environment.HBM2DDL_AUTO, "create-drop");

            configuration.setProperties(settings);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文