如何在phpMyAdmin中显示UTF-8字符?

发布于 2024-10-14 01:08:43 字数 637 浏览 2 评论 0原文

我已将数据库正确设置为 UTF-8,并且正在处理包含日语字符的数据库。如果我从 mysql 命令行执行 SELECT *...,我可以正确地看到日语字符。当从数据库中提取数据并将其显示在网页上时,我可以正确地看到它。

但是,当在 phpMyAdmin 中查看表数据时,我只看到垃圾文本。 IE。

ç§ã¯æ—¥æœææ–™ç†ãŒå¥½ãã§ã™ã€‚æ—¥æœææ–™ç†ã‚...

如何让 phpMyAdmin 显示日文字符?

HTML 页面上的字符编码设置为 UTF-8。

编辑:

我尝试导出数据库并在 geany 中打开 .sql 文件。即使编码设置为UTF-8,字符仍然是乱码。 (但是,对数据库进行mysqldump也显示乱码)。

数据库和所有表的字符集设置正确(在文件中的任何位置都找不到“拉丁语”)

CREATE DATABASE `japanese` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

我已将这些行添加到 my.cnf 并重新启动 mysql,但没有任何更改。我正在使用 Zend Framework 将数据插入数据库。

我将为这个问题悬赏,因为我真的很想弄清楚这个问题。

I have my database properly set to UTF-8 and am dealing with a database containing Japanese characters. If I do SELECT *... from the mysql command line, I properly see the Japanese characters. When pulling data out of the database and displaying it on a webpage, I see it properly.

However, when viewing the table data in phpMyAdmin, I just see garbage text. ie.

ç§ã¯æ—¥æœ¬æ–™ç†ãŒå¥½ãã§ã™ã€‚日本料ç†ã‚...

How can I get phpMyAdmin to display the characters in Japanese?

The character encoding on the HTML page is set to UTF-8.

Edit:

I have tried an export of my database and opened up the .sql file in geany. The characters are still garbled even though the encoding is set to UTF-8. (However, doing a mysqldump of the database also shows garbled characters).

The character set is set correctly for the database and all tables ('latin' is not found anywhere in the file)

CREATE DATABASE `japanese` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

I have added the lines to my.cnf and restarted mysql but there is no change. I am using Zend Framework to insert data into the database.

I am going to open a bounty for this question as I really want to figure this out.

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

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

发布评论

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

评论(18

带上头具痛哭 2024-10-21 01:08:43

不幸的是,phpMyAdmin 是第一个与 MySQL 正确讨论字符集的 PHP 应用程序之一。您的问题很可能是由于数据库一开始就没有存储正确的 UTF-8 字符串。

为了在phpMyAdmin中正确显示字符,数据必须正确存储在数据库中。然而,将数据库转换为正确的字符集通常会破坏不了解 MySQL 提供的字符集相关功能的 Web 应用程序。

请问:MySQL是>? 4.1版本?该数据库用于什么网络应用程序? phpBB?数据库是从旧版本的 Web 应用程序还是旧版本的 MySQL 迁移的?

如果您使用的网络应用程序太旧并且不受支持,我的建议是不要兄弟。仅当您确定 Web 应用程序可以正确读取数据库时,才将数据库转换为真正的 UTF-8。


编辑:

您的 MySQL 是 > 4.1,这意味着它是字符集感知的。您的数据库的字符集排序规则设置是什么?我很确定您正在使用latin1(这是 ASCII 的 MySQL 名称)将 UTF-8 文本以“字节”形式存储到数据库中。

对于字符集不敏感的客户端(即 mysql-cli 和 php-mod-mysql),字符可以正确显示,因为它们是以字节的形式传输到数据库或从数据库传输的。在 phpMyAdmin 中,字节被读取并显示为 ASCII 字符,这就是您看起来的垃圾文本。

几年前(2005 年?)当 MySQL 4.0 在亚洲许多地区过时时,已经花费了无数时间。有一种标准方法可以处理您的问题和大量数据:

  1. 将数据库备份为 .sql
  2. 在支持 UTF-8 的文本编辑器中打开它,确保它们看起来正确。
  3. 查找字符集排序规则latin1_general_ci,将latin1替换为utf8
  4. 另存为新的 sql 文件,不要覆盖您的备份
  5. 导入新文件,它们现在将在 phpMyAdmin 中正确显示,并且您的网络应用程序上的日语将变成问号。这很正常。
  6. 对于依赖 php-mod-mysql 的 php Web 应用程序,在 mysql_connect() 之后插入 mysql_query("SET NAMES UTF8");,现在问号将会消失。
  7. 为mysql-cli添加以下配置my.ini

    # 客户端部分
    [mysql]
    默认字符集=utf8
    # 服务器部分
    [mysqld]
    默认字符集=utf8
    

有关MySQL字符集的更多信息,请参阅手册:
http://dev.mysql.com/doc/refman/5.0 /en/charset-server.html

请注意,我假设您的 Web 应用程序正在使用 php-mod-mysql 连接到数据库(因此使用 mysql_connect() 函数),因为 php- mod-mysql 是我能想到的唯一一个至今仍然引发问题的扩展。

phpMyAdmin 使用 php-mod-mysqli 连接到 MySQL。我从未学习过如何使用它,因为切换到框架*来开发我的 php 项目。我强烈鼓励您也这样做。

  • 许多框架,例如 CodeIgniter、Zend,使用 mysqli 或 pdo 来连接数据库。 mod-mysql 函数被认为是过时的,导致性能和可扩展性问题。此外,您不希望将您的项目与特定类型的数据库联系起来。

Unfortunately, phpMyAdmin is one of the first php application that talk to MySQL about charset correctly. Your problem is most likely due to the fact that the database does not store the correct UTF-8 strings at first place.

In order to correctly display the characters correctly in phpMyAdmin, the data must be correctly stored in the database. However, convert the database into correct charset often breaks web apps that does not aware charset-related feature provided by MySQL.

May I ask: is MySQL > version 4.1? What web app is the database for? phpBB? Was the database migrated from an older version of the web app, or an older version of MySQL?

My suggestion is not to brother if the web app you are using is too old and not supported. Only convert database to real UTF-8 if you are sure the web app can read them correctly.


Edit:

Your MySQL is > 4.1, that means it's charset-aware. What's the charset collation settings for you database? I am pretty sure you are using latin1, which is MySQL name for ASCII, to store the UTF-8 text in 'bytes', into the database.

For charset-insensitive clients (i.e. mysql-cli and php-mod-mysql), characters get displayed correctly since they are being transfer to/from database as bytes. In phpMyAdmin, bytes get read and displayed as ASCII characters, that's the garbage text you seem.

Countless hours had been spend years ago (2005?) when MySQL 4.0 went obsolete, in many parts of Asia. There is a standard way to deal with your problem and gobbled data:

  1. Back up your database as .sql
  2. Open it up in UTF-8 capable text editor, make sure they look correct.
  3. Look for charset collation latin1_general_ci, replace latin1 to utf8.
  4. Save as a new sql file, do not overwrite your backup
  5. Import the new file, they will now look correctly in phpMyAdmin, and Japanese on your web app will become question marks. That's normal.
  6. For your php web app that rely on php-mod-mysql, insert mysql_query("SET NAMES UTF8"); after mysql_connect(), now the question marks will be gone.
  7. Add the following configuration my.ini for mysql-cli:

    # CLIENT SECTION
    [mysql]
    default-character-set=utf8
    # SERVER SECTION
    [mysqld]
    default-character-set=utf8
    

For more information about charset on MySQL, please refer to manual:
http://dev.mysql.com/doc/refman/5.0/en/charset-server.html

Note that I assume your web app is using php-mod-mysql to connect to the database (hence the mysql_connect() function), since php-mod-mysql is the only extension I can think of that still trigger the problem TO THIS DAY.

phpMyAdmin use php-mod-mysqli to connect to MySQL. I never learned how to use it because switch to frameworks* to develop my php projects. I strongly encourage you do that too.

  • Many frameworks, e.g. CodeIgniter, Zend, use mysqli or pdo to connect to databases. mod-mysql functions are considered obsolete cause performance and scalability issue. Also, you do not want to tie your project to a specific type of database.
天冷不及心凉 2024-10-21 01:08:43

如果您使用 PDO,请不要忘记使用 UTF8 启动它:(

 $con = new PDO('mysql:host=' . $server . ';dbname=' . $db . ';charset=UTF8', $user, $pass,  array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));

刚刚花了 5 个小时才弄清楚这一点,希望它能节省某人宝贵的时间......)

If you're using PDO don't forget to initiate it with UTF8:

 $con = new PDO('mysql:host=' . $server . ';dbname=' . $db . ';charset=UTF8', $user, $pass,  array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));

(just spent 5 hours to figure this out, hope it will save someone precious time...)

诠释孤独 2024-10-21 01:08:43

我做了更多的谷歌搜索,发现了 this page

该命令似乎没有意义,但我还是尝试了:

在文件 /usr/share/phpmyadmin/libraries/dbi/mysqli.dbi.lib.php 中在我添加的 return 语句之前的函数 PMA_DBI_connect() 末尾:

mysqli_query($link, "SET SESSION CHARACTER_SET_RESULTS =latin1;");
mysqli_query($link, "SET SESSION CHARACTER_SET_CLIENT =latin1;");

它有效!我现在在 phpMyAdmin 中看到日语字符。搞什么?为什么这有效?

I did a little more googling and came across this page

The command doesn't seem to make sense but I tried it anyway:

In the file /usr/share/phpmyadmin/libraries/dbi/mysqli.dbi.lib.php at the end of function PMA_DBI_connect() just before the return statement I added:

mysqli_query($link, "SET SESSION CHARACTER_SET_RESULTS =latin1;");
mysqli_query($link, "SET SESSION CHARACTER_SET_CLIENT =latin1;");

And it works! I now see Japanese characters in phpMyAdmin. WTF? Why does this work?

╰つ倒转 2024-10-21 01:08:43

我遇到了同样的问题,

将 phpMyAdmin 中的所有 text/varchar 排序规则设置为 utf-8 并在 php 文件中添加以下内容:

mysql_set_charset("utf8", $your_connection_name);

这为我解决了这个问题。

I had the same problem,

Set all text/varchar collations in phpMyAdmin to utf-8 and in php files add this:

mysql_set_charset("utf8", $your_connection_name);

This solved it for me.

薄荷梦 2024-10-21 01:08:43

解决方案很简单:

  1. 找到 phpmysqladmin 连接函数/方法,
  2. 在连接数据库后添加此$db_conect->set_charset('utf8');

the solution for this can be as easy as :

  1. find the phpmysqladmin connection function/method
  2. add this after database is conncted $db_conect->set_charset('utf8');
北城孤痞 2024-10-21 01:08:43

将 phpmyadmin->table_name->field_name 中的 latin1_swedish_ci 更改为 utf8_general_ci

这是您在屏幕上找到它的位置:

Change latin1_swedish_ci to utf8_general_ci in phpmyadmin->table_name->field_name

This is where you find it on the screen:

逆光下的微笑 2024-10-21 01:08:43

phpmyadmin 不遵循 MySQL 连接,因为它在 phpmyadmin 配置文件中定义了正确的排序规则。

因此,如果我们不想或者无法访问服务器参数,我们应该强制它以与客户端(即 phpmyadmin)兼容的不同格式(编码)发送结果,

例如,如果 MySQL 连接排序规则和 MySQL 字符集都是utf8 但 phpmyadmin 是 ISO,我们应该在通过 phpmyadmin 发送到 MYSQL 的任何选择查询之前添加这一点:

SET SESSION CHARACTER_SET_RESULTS =latin1;

phpmyadmin doesn't follow the MySQL connection because it defines its proper collation in phpmyadmin config file.

So if we don't want or if we can't access server parameters, we should just force it to send results in a different format (encoding) compatible with client i.e. phpmyadmin

for example if both the MySQL connection collation and the MySQL charset are utf8 but phpmyadmin is ISO, we should just add this one before any select query sent to the MYSQL via phpmyadmin :

SET SESSION CHARACTER_SET_RESULTS =latin1;
新雨望断虹 2024-10-21 01:08:43

以下是我如何将数据从 latin1 恢复到 utf8 而不松动的方法:

/**
     * Fixes the data in the database that was inserted into latin1 table using utf8 encoding.
     *
     * DO NOT execute "SET NAMES UTF8" after mysql_connect.
     * Your encoding should be the same as when you firstly inserted the data.
     * In my case I inserted all my utf8 data into LATIN1 tables.
     * The data in tables was like ДЕТСКИÐ.
     * But my page presented the data correctly, without "SET NAMES UTF8" query.
     * But phpmyadmin did not present it correctly.
     * So this is hack how to convert your data to the correct UTF8 format.
     * Execute this code just ONCE!
     * Don't forget to make backup first!
     */
    public function fixIncorrectUtf8DataInsertedByLatinEncoding() {
        // mysql_query("SET NAMES LATIN1") or die(mysql_error()); #uncomment this if you already set UTF8 names somewhere

        // get all tables in the database
        $tables = array();
        $query = mysql_query("SHOW TABLES");
        while ($t = mysql_fetch_row($query)) {
            $tables[] = $t[0];
        }
        // you need to set explicit tables if not all tables in your database are latin1 charset
        // $tables = array('mytable1', 'mytable2', 'mytable3'); # uncomment this if you want to set explicit tables

        // duplicate tables, and copy all data from the original tables to the new tables with correct encoding
        // the hack is that data retrieved in correct format using latin1 names and inserted again utf8
        foreach ($tables as $table)  {
            $temptable = $table . '_temp';
            mysql_query("CREATE TABLE $temptable LIKE $table") or die(mysql_error());
            mysql_query("ALTER TABLE $temptable CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci") or die(mysql_error());
            $query = mysql_query("SELECT * FROM `$table`") or die(mysql_error());
            mysql_query("SET NAMES UTF8") or die(mysql_error());
            while ($row = mysql_fetch_row($query)) {
                $values = implode("', '", $row);
                mysql_query("INSERT INTO `$temptable` VALUES('$values')") or die(mysql_error());
            }
            mysql_query("SET NAMES LATIN1") or die(mysql_error());
        }

        // drop old tables and rename temporary tables
        // this actually should work, but it not, then
        // comment out this lines if this would not work for you and try to rename tables manually with phpmyadmin
        foreach ($tables as $table)  {
            $temptable = $table . '_temp';
            mysql_query("DROP TABLE `$table`") or die(mysql_error());
            mysql_query("ALTER TABLE `$temptable` RENAME `$table`") or die(mysql_error());
        }
        // now you data should be correct

        // change the database character set
        mysql_query("ALTER DATABASE DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci") or die(mysql_error());

        // now you can use "SET NAMES UTF8" in your project and mysql will use corrected data
    }

Here is my way how do I restore the data without looseness from latin1 to utf8:

/**
     * Fixes the data in the database that was inserted into latin1 table using utf8 encoding.
     *
     * DO NOT execute "SET NAMES UTF8" after mysql_connect.
     * Your encoding should be the same as when you firstly inserted the data.
     * In my case I inserted all my utf8 data into LATIN1 tables.
     * The data in tables was like ДЕТСКИÐ.
     * But my page presented the data correctly, without "SET NAMES UTF8" query.
     * But phpmyadmin did not present it correctly.
     * So this is hack how to convert your data to the correct UTF8 format.
     * Execute this code just ONCE!
     * Don't forget to make backup first!
     */
    public function fixIncorrectUtf8DataInsertedByLatinEncoding() {
        // mysql_query("SET NAMES LATIN1") or die(mysql_error()); #uncomment this if you already set UTF8 names somewhere

        // get all tables in the database
        $tables = array();
        $query = mysql_query("SHOW TABLES");
        while ($t = mysql_fetch_row($query)) {
            $tables[] = $t[0];
        }
        // you need to set explicit tables if not all tables in your database are latin1 charset
        // $tables = array('mytable1', 'mytable2', 'mytable3'); # uncomment this if you want to set explicit tables

        // duplicate tables, and copy all data from the original tables to the new tables with correct encoding
        // the hack is that data retrieved in correct format using latin1 names and inserted again utf8
        foreach ($tables as $table)  {
            $temptable = $table . '_temp';
            mysql_query("CREATE TABLE $temptable LIKE $table") or die(mysql_error());
            mysql_query("ALTER TABLE $temptable CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci") or die(mysql_error());
            $query = mysql_query("SELECT * FROM `$table`") or die(mysql_error());
            mysql_query("SET NAMES UTF8") or die(mysql_error());
            while ($row = mysql_fetch_row($query)) {
                $values = implode("', '", $row);
                mysql_query("INSERT INTO `$temptable` VALUES('$values')") or die(mysql_error());
            }
            mysql_query("SET NAMES LATIN1") or die(mysql_error());
        }

        // drop old tables and rename temporary tables
        // this actually should work, but it not, then
        // comment out this lines if this would not work for you and try to rename tables manually with phpmyadmin
        foreach ($tables as $table)  {
            $temptable = $table . '_temp';
            mysql_query("DROP TABLE `$table`") or die(mysql_error());
            mysql_query("ALTER TABLE `$temptable` RENAME `$table`") or die(mysql_error());
        }
        // now you data should be correct

        // change the database character set
        mysql_query("ALTER DATABASE DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci") or die(mysql_error());

        // now you can use "SET NAMES UTF8" in your project and mysql will use corrected data
    }
送你一个梦 2024-10-21 01:08:43

首先,从客户端执行

mysql> SHOW VARIABLES LIKE 'character_set%';

这将为您提供类似的信息,

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     | 
| character_set_connection | latin1                     | 
| character_set_database   | latin1                     | 
| character_set_filesystem | binary                     | 
| character_set_results    | latin1                     | 
| character_set_server     | latin1                     | 
| character_set_system     | utf8                       | 
| character_sets_dir       | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+

您可以在其中检查客户端、连接、数据库的常规设置

然后您还应该检查从中检索数据的列

SHOW CREATE TABLE TableName

并检查 CHAR 字段的字符集和排序规则(尽管通常人们不会显式设置它们,但可以在 CREATE TABLE foo ADD COLUMN foo CHAR .. 中给出 CHAR[(length)] [CHARACTER SET charset_name] [COLLATE collat​​ion_name] .

我相信我已经在mysql这边列出了所有相关设置。
如果仍然迷路,请阅读docs,也许这个问题这可能会带来一些启发(特别是我认为我在第一次只查看mysql客户端时就得到了正确的结果) 。

First, from the client do

mysql> SHOW VARIABLES LIKE 'character_set%';

This will give you something like

+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | latin1                     | 
| character_set_connection | latin1                     | 
| character_set_database   | latin1                     | 
| character_set_filesystem | binary                     | 
| character_set_results    | latin1                     | 
| character_set_server     | latin1                     | 
| character_set_system     | utf8                       | 
| character_sets_dir       | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+

where you can inspect the general settings for the client, connection, database

Then you should also inspect the columns from which you are retrieving data with

SHOW CREATE TABLE TableName

and inspecting the charset and collation of CHAR fields (though usually people do not set them explicitly, but it is possible to give CHAR[(length)] [CHARACTER SET charset_name] [COLLATE collation_name] in CREATE TABLE foo ADD COLUMN foo CHAR ...)

I believe that I have listed all relevant settings on the side of mysql.
If still getting lost read fine docs and perhaps this question which might shed some light (especially how I though I got it right by looking only at mysql client in the first go).

仲春光 2024-10-21 01:08:43

1- 打开文件:

C:\wamp\bin\mysql\mysql5.5.24\my.ini

2- 查找 [mysqld] 条目并附加:

character-set-server = utf8
skip-character-set-client-handshake

整个视图应如下所示

[mysqld]
  port=3306
  character-set-server = utf8
  skip-character-set-client-handshake

3- 重新启动 MySQL 服务!

1- Open file:

C:\wamp\bin\mysql\mysql5.5.24\my.ini

2- Look for [mysqld] entry and append:

character-set-server = utf8
skip-character-set-client-handshake

The whole view should look like:

[mysqld]
  port=3306
  character-set-server = utf8
  skip-character-set-client-handshake

3- Restart MySQL service!

ゃ懵逼小萝莉 2024-10-21 01:08:43

如果您在 myphpadmin 中显示 garbdata,那么在 myphpadmin 中添加多语言非常简单,只需转到 myphpadmin 单击您的数据库,转到操作选项卡页面中的操作选项卡,查看排序规则部分,将其设置为 utf8_general_ci,之后您的所有 garbdata 将正确显示。一个简单又容易的技巧

Its realy simple to add multilanguage in myphpadmin if you got garbdata showing in myphpadmin, just go to myphpadmin click your database go to operations tab in operation tab page see collation section set it to utf8_general_ci, after that all your garbdata will show correctly. a simple and easy trick

桜花祭 2024-10-21 01:08:43

函数和文件名与较新版本的 phpMyAdmin 中的不匹配。以下是在较新的 PHPMyAdmins 中修复的方法:

  1. 查找文件:
    phpmyadmin/libraries/DatabaseInterface.php

  2. 在函数中:公共函数查询

  3. 在开头 { 之后添加以下内容:

    if($link != null){
        mysqli_query($link, "设置会话字符_SET_RESULTS =latin1;");
        mysqli_query($link, "设置会话字符_SET_CLIENT =latin1;");
    }
    

就是这样。就像魅力一样。

The function and file names don't match those in newer versions of phpMyAdmin. Here is how to fix in the newer PHPMyAdmins:

  1. Find file:
    phpmyadmin/libraries/DatabaseInterface.php

  2. In function: public function query

  3. Right after the opening { add this:

    if($link != null){
        mysqli_query($link, "SET SESSION CHARACTER_SET_RESULTS =latin1;");
        mysqli_query($link, "SET SESSION CHARACTER_SET_CLIENT =latin1;");
    }
    

That's it. Works like a charm.

家住魔仙堡 2024-10-21 01:08:43

我有完全相同的问题。数据库字符集是utf-8,排序规则是utf8_unicode_ci。我能够在我的 web 应用程序中看到 Unicode 文本,但 phpMyAdmin 和 sqldump 结果是乱码。

事实证明,问题出在我的 Web 应用程序连接 MySQL 的方式上。我缺少编码标志。

修复此问题后,我能够在 phpMyAdmin 和 sqldump 中正确看到希腊字符,但丢失了我以前的所有条目

I had exactly the same problem. Database charset is utf-8 and collation is utf8_unicode_ci. I was able to see Unicode text in my webapp but the phpMyAdmin and sqldump results were garbled.

It turned out that the problem was in the way my web application was connecting to MySQL. I was missing the encoding flag.

After I fixed it, I was able to see Greek characters correctly in both phpMyAdmin and sqldump but lost all my previous entries.

快乐很简单 2024-10-21 01:08:43

只需在libraries/database_interface.lib.php中取消注释此行,

if (! empty($GLOBALS['collation_connection'])) {
       // PMA_DBI_query("SET CHARACTER SET 'utf8';", $link, PMA_DBI_QUERY_STORE);
       //PMA_DBI_query("SET collation_connection = '" .
       //PMA_sqlAddslashes($GLOBALS['collation_connection']) . "';", $link, PMA_DBI_QUERY_STORE);
} else {
       //PMA_DBI_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci';", $link, PMA_DBI_QUERY_STORE);
 }

如果您以utf8存储数据而不存储字符集,则不需要phpmyadmin再次重新转换连接。这会起作用。

just uncomment this lines in libraries/database_interface.lib.php

if (! empty($GLOBALS['collation_connection'])) {
       // PMA_DBI_query("SET CHARACTER SET 'utf8';", $link, PMA_DBI_QUERY_STORE);
       //PMA_DBI_query("SET collation_connection = '" .
       //PMA_sqlAddslashes($GLOBALS['collation_connection']) . "';", $link, PMA_DBI_QUERY_STORE);
} else {
       //PMA_DBI_query("SET NAMES 'utf8' COLLATE 'utf8_general_ci';", $link, PMA_DBI_QUERY_STORE);
 }

if you store data in utf8 without storing charset you do not need phpmyadmin to re-convert again the connection. This will work.

自此以后,行同陌路 2024-10-21 01:08:43

wamp 更简单的解决方案是:
转到 phpMyAdmin,
单击本地主机,
选择 latin1_bin 作为服务器连接排序规则,
然后开始创建数据库和表

Easier solution for wamp is:
go to phpMyAdmin,
click localhost,
select latin1_bin for Server connection collation,
then start to create database and table

み青杉依旧 2024-10-21 01:08:43

添加:

mysql_query("SET NAMES UTF8");

如下:

mysql_select_db(/*your_database_name*/);

Add:

mysql_query("SET NAMES UTF8");

below:

mysql_select_db(/*your_database_name*/);
め七分饶幸 2024-10-21 01:08:43

它对我有用,

mysqli_query($con, "SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");

It works for me,

mysqli_query($con, "SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
若水般的淡然安静女子 2024-10-21 01:08:43

更改表 table_name 转换为字符集 utf8;

*重要提示:先备份,后执行

ALTER TABLE table_name CONVERT to CHARACTER SET utf8;

*IMPORTANT: Back-up first, execute after

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