更改 phpmyadmin 中的默认排序规则

发布于 2024-07-06 06:14:45 字数 61 浏览 8 评论 0原文

在我看来,phpMyAdmin 默认使用排序规则 latin1_swedish_ci 导入表,我如何更改它?

It seems to me that phpMyAdmin imports tables by default with collation latin1_swedish_ci, how i change this?

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

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

发布评论

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

评论(9

娇女薄笑 2024-07-13 06:14:45

在您的 Mysql 配置中,更改 [mysqld] 选项卡下的默认字符集操作。 例如:

[mysqld]
default-character-set=utf8

之后不要忘记重新启动 Mysql 服务器以使更改生效。

In your Mysql configuration change the default-character-set operative under the [mysqld] tab. For example:

[mysqld]
default-character-set=utf8

Don't forget to restart your Mysql server afterwards for the changes to take effect.

_失温 2024-07-13 06:14:45

对于 Linux:

  1. 您需要有权访问 MySQL 配置文件。
    该位置可能有所不同,从 /etc/mysql/my.cnf~/my.cnf(用户目录)。

  2. [mysqld]部分添加以下行:

    collat​​ion_server = utf8_unicode_ci 
      字符集服务器=utf8 
      
  3. 重新启动服务器:

    服务 mysqld 重新启动 
      

For Linux:

  1. You need to have access to the MySQL config file.
    The location can vary from /etc/mysql/my.cnf to ~/my.cnf (user directory).

  2. Add the following lines in the section [mysqld]:

    collation_server = utf8_unicode_ci
    character_set_server=utf8
    
  3. Restart the server:

    service mysqld restart
    
倾`听者〃 2024-07-13 06:14:45

这不是 phpMyAdmin 问题。

排序规则是最新 MySQL 版本的一部分,您必须设置服务器(或至少是数据库)的默认排序规则才能更改该行为。

要将已导入的表转换为 UTF-8,您可以执行以下操作(在 PHP 中):

$dbname = 'my_databaseName';
mysql_connect('127.0.0.1', 'root', '');
mysql_query("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
$res = mysql_query("SHOW TABLES FROM `$dbname`");
while($row = mysql_fetch_row($res)) {
   $query = "ALTER TABLE {$dbname}.`{$row[0]}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
   mysql_query($query);
   $query = "ALTER TABLE {$dbname}.`{$row[0]}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
   mysql_query($query);
}
echo 'all tables converted';

代码片段取自 此处

This is not a phpMyAdmin question.

Collations are part of recent MySQL releases, you must set the default collation of the server (or at least of the database) to change that behaviour.

To convert already imported tables to UTF-8 you can do (in PHP):

$dbname = 'my_databaseName';
mysql_connect('127.0.0.1', 'root', '');
mysql_query("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
$res = mysql_query("SHOW TABLES FROM `$dbname`");
while($row = mysql_fetch_row($res)) {
   $query = "ALTER TABLE {$dbname}.`{$row[0]}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
   mysql_query($query);
   $query = "ALTER TABLE {$dbname}.`{$row[0]}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
   mysql_query($query);
}
echo 'all tables converted';

Code snippet taken from here.

你另情深 2024-07-13 06:14:45

对于 utf8mb4,在 [mysqld] 部分中添加/更改以下内容:

collation_server = utf8mb4_unicode_ci
character_set_server = utf8mb4

然后重新启动 mysql 服务(对于 Ubuntu,命令为 sudo 服务 mysql 重新启动)

For utf8mb4, add/change the following in the [mysqld] section:

collation_server = utf8mb4_unicode_ci
character_set_server = utf8mb4

Then restart the mysql service (for Ubuntu the command is sudo service mysql restart)

氛圍 2024-07-13 06:14:45

知道这是一个旧帖子。 但我通过phpMyAdmin更改默认字符集的方式是:

phpMyadmin主页> 变量选项卡(服务器变量和设置)> 搜索“character”并将所有变量从“latin1”更改为“utf8”。
(在使用 phpMyAdmin v.3.5.7 的 MAMP 安装上)

正如其他人所说,这是 MySQL 的变量,而不是某些 phpMyAdmin 特定的变量。

know this is an old post. But the way i changed the default charset through phpMyAdmin was:

phpMyadmin main page > Variables tab (Server variables and settings) > searched for "character" and changed all variables from "latin1" to "utf8".
(on a MAMP installation with phpMyAdmin v. 3.5.7)

And as the others said, this is the variables for MySQL and not some phpMyAdmin specific ones.

情绪操控生活 2024-07-13 06:14:45

MySQL DB « 更改排序规则 数据库名称|表为 utf8_general_ci 以支持 Unicode。

更改


XAMPP 的配置设置文件:
从配置设置文件中取消注释 UTF 8 Settings « D:\xampp\mysql\bin\my.ini

## UTF 8 Settings
#init-connect=\'SET NAMES utf8\'
collation_server=utf8_unicode_ci
character_set_server=utf8
skip-character-set-client-handshake
character_sets-dir="D:/xampp/mysql/share/charsets"

让 MySQL 服务器支持 UTF8 以及文件中的以下代码行my.cnf

## UTF 8 Settings
collation_server=utf8_unicode_ci
character_set_server=utf8

@see

MySQL DB « change Collation Name of a Database|Table to utf8_general_ci inorder to support Unicode.

Change Configuration settings file also


XAMPP:
uncomment UTF 8 Settings from the Configuration settings file « D:\xampp\mysql\bin\my.ini

## UTF 8 Settings
#init-connect=\'SET NAMES utf8\'
collation_server=utf8_unicode_ci
character_set_server=utf8
skip-character-set-client-handshake
character_sets-dir="D:/xampp/mysql/share/charsets"

For MySQL server to support UTF8 and the below line of code in file my.cnf

## UTF 8 Settings
collation_server=utf8_unicode_ci
character_set_server=utf8

@see

怪我闹别瞎闹 2024-07-13 06:14:45
  1. 将此字符串插入 my.ini (或 my.cnf
[mysqld]
collation_server = utf8_unicode_ci
character_set_server=utf8
  1. 添加到 config.inc.php
$cfg['DefaultConnectionCollation'] = 'utf8_general_ci';
  1. 您需要重新启动MySQL 服务器并删除 cookie、所在域的数据 PhpMyAdmin

  2. 使用PhpMyAmdin重新加载页面并查看结果

< a href="https://i.sstatic.net/hCHVF.png" rel="nofollow noreferrer">输入图像描述这里

  1. Insert this strings into my.ini (or my.cnf)
[mysqld]
collation_server = utf8_unicode_ci
character_set_server=utf8
  1. Add into config.inc.php
$cfg['DefaultConnectionCollation'] = 'utf8_general_ci';
  1. You need to restart MySQL server and remove cookies,data for domain where is located PhpMyAdmin

  2. Reload page with PhpMyAmdin and at look the result

enter image description here

故乡的云 2024-07-13 06:14:45

最初的问题是关于 phpMyAdmin 中的默认设置。
我认为问题与在 phpMyAdmin 中创建新数据库有关 - 当页面显示 utf8mb4 时...
这是 phpMyAdmin 设置!
如果您希望创建新数据库时默认显示 utf8_general_ci。
将以下 2 行添加到 config.inc.php 文件中:

$cfg['DefaultCharset'] = 'utf8';

$cfg['DefaultConnectionCollat​​ion'] = 'utf8_general_ci';$cfg['DefaultConnectionCollat​​ion'] = 'utf8_general_ci'; 代码>

请参阅 phpMyAdmin 文档 https://docs.phpmyadmin.net/en/latest/config .html
https://docs.phpmyadmin.net/en/latest/config.html# cfg_DefaultConnectionCollat​​ion

The original question was for the default setting in phpMyAdmin.
I think the question relates to creating a NEW database in phpMyAdmin - when the page shows utf8mb4...
This IS a phpMyAdmin setting!
If you want the default for creating new databases to show utf8_general_ci.
Add the following 2 line to your config.inc.php file:

$cfg['DefaultCharset'] = 'utf8';

$cfg['DefaultConnectionCollation'] = 'utf8_general_ci';

See phpMyAdmin docs https://docs.phpmyadmin.net/en/latest/config.html and
https://docs.phpmyadmin.net/en/latest/config.html#cfg_DefaultConnectionCollation

小苏打饼 2024-07-13 06:14:45

我想改用 utf8mb4,配置必须如下:

collation_server = utf8mb4_general_ci
character_set_server=utf8mb4

如果将 character_set 设置为 utf8,服务器将不会启动

I wanted to use utf8mb4 instead, and the configuration had to be the following:

collation_server = utf8mb4_general_ci
character_set_server=utf8mb4

the server would not start if the character_set was set to utf8

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