这是我使用的命令:
ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
效果很好。现在,我需要为列设置utf8mb4_unicode_ci
(因为当前字符显示为???
)。无论如何,这是我的新命令:
ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8 COLLATE utf8mb4_unicode_ci;
可悲的是MySQL抛出:
ERROacR 1253(42000):COLLECTION'utf8mb4_unicode_ci'对CHARACTER无效
有什么主意吗?
答案 0 :(得分:1)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
<script src="https://rawgit.com/lethexa/leaflet-tracksymbol/master/leaflet-tracksymbol.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
<script src="https://rawgit.com/evanplaice/jquery-csv/master/src/jquery.csv.js"></script>
</head>
<body>
<div id="map" style="width: 600px; height: 400px;"></div>
<script>
var map = L.map('map').setView([25.93, 51.61], 6);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
$.ajax({
type: "GET",
url: "boats.csv",
dataType: "text",
success: function(data) {
dat2 = $.csv.toObjects(data);
for (var i = 0; i < dat2.length; i++){
var latlng = L.latLng(dat2[i].latitude, dat2[i].longitude)
L.trackSymbol(latlng, {
speed: dat2[i].speed,
course: dat2[i].course,
heading: dat2[i].heading,
fillColor: dat2[i].fillColor
}).addTo(map);
}
}
});
</script>
</body>
</html>
名称的第一部分必须与COLLATION
名称匹配。
CHARACTER SET
。
让我们回到问号的“真正”问题上。
CHARACTER SET utf8mb4
是指排序和排序规则,而不是编码。
COLLATION
是指编码。这在所有阶段都应保持一致。问号来自不一致之处。
Trouble with UTF-8 characters; what I see is not what I stored指出这些是问号的可能嫌疑人:
答案 1 :(得分:0)
这对我有用:
ALTER TABLE <table_name> MODIFY <column_name> VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;