我的本地计算机上有一个WordPress数据库,我希望将其转移到cPanel上的托管phpMyAdmin。但是,当我尝试将数据库导入到环境中时,会不断出现此错误:
#1273 - Unknown collation: 'utf8mb4_unicode_ci'
我已经尝试过使用Google,但唯一可以找到的解决方案是phpmysql error - #1273 - #1273 - Unknown collation: 'utf8mb4_general_ci',目前为止并没有太大帮助。我曾尝试清除Cookie,但仍然无法正常工作。请帮忙!
最佳答案
我遇到了同样的问题,因为我们所有的服务器都运行旧版本的MySQL。这可以通过运行PHP脚本来解决。将此代码保存到文件中并运行它,输入数据库名称,用户名和密码,它将归类从utf8mb4/utf8mb4_unicode_ci
更改为utf8/utf8_general_ci
<!DOCTYPE html>
<html>
<head>
<title>DB-Convert</title>
<style>
body { font-family:"Courier New", Courier, monospace; }
</style>
</head>
<body>
<h1>Convert your Database to utf8_general_ci!</h1>
<form action="db-convert.php" method="post">
dbname: <input type="text" name="dbname"><br>
dbuser: <input type="text" name="dbuser"><br>
dbpass: <input type="text" name="dbpassword"><br>
<input type="submit">
</form>
</body>
</html>
<?php
if ($_POST) {
$dbname = $_POST['dbname'];
$dbuser = $_POST['dbuser'];
$dbpassword = $_POST['dbpassword'];
$con = mysql_connect('localhost',$dbuser,$dbpassword);
if(!$con) { echo "Cannot connect to the database ";die();}
mysql_select_db($dbname);
$result=mysql_query('show tables');
while($tables = mysql_fetch_array($result)) {
foreach ($tables as $key => $value) {
mysql_query("ALTER TABLE $value CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci");
}}
echo "<script>alert('The collation of your database has been successfully changed!');</script>";
}
?>