我在本地WAMP服务器上有一个WordPress网站。但当我上传它的数据库到活服务器,我得到错误
#1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’
任何帮助都将不胜感激!
我在本地WAMP服务器上有一个WordPress网站。但当我上传它的数据库到活服务器,我得到错误
#1273 – Unknown collation: ‘utf8mb4_unicode_520_ci’
任何帮助都将不胜感激!
当前回答
Getting collation error #1273 - Unknown collation: 'utf8mb4_unicode_520_ci' is caused by the difference of the MySQL version from which you export and our MySQL server to which you import. Basically, the Wordpress library for newer version checks to see what version of SQL your site is running on. If it uses MySQL version 5.6 or more, it assumes the use of a new and improved Unicode Collation Algorithm (UCA) called “utf8mb4_unicode_520_ci”. This is great unless you end up moving your WordPress site from a newer 5.6 version of MySQL to an older, pre 5.6 version of MySQL.
要解决这个问题,你必须编辑你的SQL导出文件,并进行搜索和替换,将' utf8mb4_unicode_520_ci '的所有实例更改为' utf8mb4_unicode_ci '。如果你有PHPMyAdmin,也可以按照下面的步骤:
单击数据库的Export选项卡 单击Custom单选按钮。 进入“特定格式选项”部分,更改数据库系统或旧MySQL服务器的下拉菜单,以最大限度地提高输出兼容性:从NONE到MYSQL40。 滚动到底部并单击GO。
其他回答
虽然有点晚了,但以防WORDPRESS安装出现这种情况:
#1273 -未知排序:'utf8mb4_unicode_520_ci
在phpmyadmin中,导出方法>格式特定选项(自定义导出)
设置为:MYSQL40
如果你现在尝试导入,你现在可能会得到另一个错误消息:
1064 -你的SQL语法错误;…
这是因为在MySQL 5.5中,与ENGINE同义的旧TYPE选项被删除了。
打开.sql文件,搜索并替换所有实例
从TYPE=到ENGINE=
现在导入应该很顺利了。
Getting collation error #1273 - Unknown collation: 'utf8mb4_unicode_520_ci' is caused by the difference of the MySQL version from which you export and our MySQL server to which you import. Basically, the Wordpress library for newer version checks to see what version of SQL your site is running on. If it uses MySQL version 5.6 or more, it assumes the use of a new and improved Unicode Collation Algorithm (UCA) called “utf8mb4_unicode_520_ci”. This is great unless you end up moving your WordPress site from a newer 5.6 version of MySQL to an older, pre 5.6 version of MySQL.
要解决这个问题,你必须编辑你的SQL导出文件,并进行搜索和替换,将' utf8mb4_unicode_520_ci '的所有实例更改为' utf8mb4_unicode_ci '。如果你有PHPMyAdmin,也可以按照下面的步骤:
单击数据库的Export选项卡 单击Custom单选按钮。 进入“特定格式选项”部分,更改数据库系统或旧MySQL服务器的下拉菜单,以最大限度地提高输出兼容性:从NONE到MYSQL40。 滚动到底部并单击GO。
我用这种方式解决了这个问题,我在记事本中打开。sql文件,单击CTRL + H找到并替换字符串“utf8mb4_0900_ai_ci”,并将其替换为“utf8mb4_general_ci”。
在我的例子中,我像这样用sed替换utf8_general_ci:
sed -i 's/utf8mb4_0900_ai_ci/utf8_general_ci/g' MY_DB.sql
sed -i 's/utf8mb4_unicode_520_ci/utf8_general_ci/g' MY_DB.sql
之后,我就可以导入了。
经过一番调查,我发现在目标服务器上运行的MySQL服务器的版本比源服务器的版本要旧。因此,我们知道目标服务器不包含所需的数据库排序规则。
然后我们在备份文件中做一点调整来解决这个问题。在文本编辑器中编辑数据库备份文件(your_sql_file.sql),将utf8mb4_0900_ai_ci替换为utf8mb4_general_ci,将CHARSET=utf8mb4替换为CHARSET=utf8。
我希望这个解决方案能帮助到你。