将脚本传输到新服务器后,编码文件名与 beetwen SQL 和文件系统不匹配
Encoding filenames mismatch beetwen SQL and filesystem after transfer of script to new server
我已将我的 Drupal 站点移至新服务器。不幸的是,现在我所有包含波兰语字母的文件 links 都坏了。
我查看了 script/database/file 系统以找出错误并发现以下内容:
- Drupal 显示以下错误:
/sites/default/files/Baranowska_Badania%20naukowe%20i%20testowanie%20nowych%20lek%C3%B3w%20na%20ludziach%20i%20zwierz%C4%99tach-aspekt%20prawny%20i%20etyczny_0.pdf
- 该文件存在于服务器上并且可以访问,但位于以下位置
link:
http://ppes.mage.pl/sites/default/files/Baranowska_Badania%20naukowe%20i%20testowanie%20nowych%20lekow%20na%20ludziach%20i%20zwierzetach-aspekt%20prawny%20i%20etyczny_0.pdf
- 在 mysql 中,文件 link 如下所示:
public://Baranowska_Badania naukowe i testowanie nowych leków na ludziach i zwierzętach-aspekt prawny i etyczny_0.pdf
如您所见,问题出在 link 编码上。 SQL 中的文件名包含波兰语字母,而 linux 系统中的真实文件名不包含波兰语字母。
我想问你是否有任何简单的方法可以解决这个问题,或者唯一的方法是手动将数据库中的所有波兰语字符替换为它们各自的非波兰语等价物(例如。“ę”=> "e" ; "ó" => "o")?
- 使用 Transliteration module 将所有文件名转换为 US-ASCII。
- 检查本地主机和远程服务器的数据库字符集和排序规则。 https://dev.mysql.com/doc/refman/5.0/en/charset-applications.html
最后我执行了以下查询:
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ą́', 'a');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ę', 'e');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ż', 'z');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ź', 'z');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ó', 'o');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ś', 's');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ć', 'c');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ś', 'S');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ź', 'Z');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ż', 'Z');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ń', 'N');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ń', 'n');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ł', 'L');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ł', 'l');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ł', 'L');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ł', 'l');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ą́', 'a');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ę', 'e');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ż', 'z');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ź', 'z');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ó', 'o');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ś', 's');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ć', 'c');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ś', 'S');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ż', 'Z');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ź', 'Z');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ń', 'N');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ń', 'n');
我已将我的 Drupal 站点移至新服务器。不幸的是,现在我所有包含波兰语字母的文件 links 都坏了。
我查看了 script/database/file 系统以找出错误并发现以下内容:
- Drupal 显示以下错误:
/sites/default/files/Baranowska_Badania%20naukowe%20i%20testowanie%20nowych%20lek%C3%B3w%20na%20ludziach%20i%20zwierz%C4%99tach-aspekt%20prawny%20i%20etyczny_0.pdf
- 该文件存在于服务器上并且可以访问,但位于以下位置 link:
http://ppes.mage.pl/sites/default/files/Baranowska_Badania%20naukowe%20i%20testowanie%20nowych%20lekow%20na%20ludziach%20i%20zwierzetach-aspekt%20prawny%20i%20etyczny_0.pdf
- 在 mysql 中,文件 link 如下所示:
public://Baranowska_Badania naukowe i testowanie nowych leków na ludziach i zwierzętach-aspekt prawny i etyczny_0.pdf
如您所见,问题出在 link 编码上。 SQL 中的文件名包含波兰语字母,而 linux 系统中的真实文件名不包含波兰语字母。
我想问你是否有任何简单的方法可以解决这个问题,或者唯一的方法是手动将数据库中的所有波兰语字符替换为它们各自的非波兰语等价物(例如。“ę”=> "e" ; "ó" => "o")?
- 使用 Transliteration module 将所有文件名转换为 US-ASCII。
- 检查本地主机和远程服务器的数据库字符集和排序规则。 https://dev.mysql.com/doc/refman/5.0/en/charset-applications.html
最后我执行了以下查询:
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ą́', 'a');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ę', 'e');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ż', 'z');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ź', 'z');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ó', 'o');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ś', 's');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ć', 'c');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ś', 'S');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ź', 'Z');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ż', 'Z');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ń', 'N');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ń', 'n');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'Ł', 'L');
UPDATE file_managed SET `filename` = REPLACE(`filename`, 'ł', 'l');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ł', 'L');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ł', 'l');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ą́', 'a');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ę', 'e');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ż', 'z');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ź', 'z');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ó', 'o');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ś', 's');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ć', 'c');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ś', 'S');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ż', 'Z');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ź', 'Z');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'Ń', 'N');
UPDATE file_managed SET `uri` = REPLACE(`uri`, 'ń', 'n');