用mysql做文件导出时报错——工作笔记

使用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>

注释掉,解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值