使用mysql --default-character-set=utf8 -h192.168.0.1 -uroot -proot -P3306 -D test -e "sql语句" | sed 's/\t/,/g' >/opt/test_001.csv
命令做文件导出时报:
Character set ‘utf8’ is not a compiled character set and is not specified in the ‘/usr/share/mysql/charsets/Index.xml’ file
根据目录找到文件Index.xml
并用vi编辑,查找utf8,找到如下配置:
<charset name="utf8">
<family>Unicode</family>
<description>UTF-8 Unicode</description>
<alias>utf-8</alias>
<collation name="utf8_general_ci" id="33">
<flag>primary</flag>
<flag>compiled</flag>
</collation>
<collation name="utf8_bin" id="83">
<flag>binary</flag>
<flag>compiled</flag>
</collation>
</charset>
有配置啊,为啥不行呢?继续往下扒,然后发现了它,这里是utf8mb4的配置。
<charset name="utf8mb4">
<family>Unicode</family>
<description>UTF-8 Unicode</description>
<alias>utf8</alias>
<collation name="utf8_general_ci" id="33">
<flag>primary</flag>
<flag>compiled</flag>
</collation>
<collation name="utf8_bin" id="83">
<flag>binary</flag>
<flag>compiled</flag>
</collation>
</charset>
注释掉,解决!