惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Recent Announcements
Recent Announcements
雷峰网
雷峰网
Last Week in AI
Last Week in AI
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
量子位
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Blog — PlanetScale
Blog — PlanetScale
F
Full Disclosure
D
DataBreaches.Net
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
MyScale Blog
MyScale Blog
美团技术团队
V
V2EX
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
腾讯CDC
Vercel News
Vercel News
A
About on SuperTechFans
J
Java Code Geeks
Martin Fowler
Martin Fowler
V
Visual Studio Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
Engineering at Meta
Engineering at Meta
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - emanlee

ubuntu 设置北京日期时间 安装 yarn npm : 无法加载文件 C:\Program Files\nodejs\npm.ps1,因为在此系统上禁止运行脚本。 - emanlee VS code, 最近打开过哪些项目或文件夹,把这些备份下来,到另外一台电脑上恢复 傲梅分区助手 【好用】 ubuntu 可以使用Windows远程桌面连接吗?【可以】 把xshell的全部连接和密码,从一台Windows 10电脑,迁移到Windows11电脑。 Windows 远程桌面(mstsc)完整迁移方案(含历史连接记录、RDP 配置、保存的账号密码)【可行】 Endnote,如何能完整迁移库和模版 ubuntu 安装 locate “华为杯”第八届中国研究生人工智能创新大赛 当数据量很大时,执行 mysql> source filename.sql 很慢,有什么办法更快 pip install django-ranged-response==0.2.0 部署Vue+Django 04c,mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory Ubuntu Server 24.04 安装 MySQL, ./mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory ubuntu server 24.04: 如何设置默认采用 Xorg 方式登录 Ubuntu Server 24.04 设置锁屏时间 Ubuntu Server 启动过程中,比较慢 Job systemd-networkd-wait-online.service/start running Ubuntu Server 24.04 启用root用户 Ubuntu snap install 安装todesk是否必须检查 CPU 是否支持 AVX / AVX2 命令 Ubuntu Server 24.04下解决SunloginClient 向日葵依赖libgconf-2-4安装问题 Ubuntu Server 24.04 安装图形界面 ubuntu server 24.04 安装 中文输入法 Ubuntu Server 24.04 安装浏览器firefox Ubuntu Server 24.04 安装todesk【先联网,CPU必须支持 AVX / AVX2 】 Ubuntu Server 24.04 安装中文,汉字 Python赋值,什么时候传引用? 大驼峰命名法 python 容易理解类和对象的例子 django+mysql: 如何添加一个新的超级用户?
mysql 在新电脑上导入,出现错误:ERROR at line 4019: Unknown command '\''. - emanlee
emanlee · 2026-07-06 · via 博客园 - emanlee

在新电脑上导入,出现错误:

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p < E:\mysql_full_backup.sql

Enter password: *************

ERROR at line 4019: Unknown command '\''.

报错原因

Unknown command '\'' 典型三种情况:

  1. 备份文件路径 / 文件名含中文、空格、特殊符号;
  2. SQL 文件是 Windows 换行编码、导出时编码错乱,单引号 ' 解析异常;
  3. 导出 / 拷贝过程文件损坏、文件编码非 UTF-8;
  4. CMD 重定向 < 导入对特殊字符兼容性差。

方案一:改用 source 命令导入(最稳,优先试) 【不行,仍然错误

  1. 进入 bin 目录登录 MySQL
  1. 执行 source,路径用正斜杠 /
source E:/mysql_full_backup.sql; 

方案二:修复文件编码问题(上面还报错再操作)

  1. 右键 E:\mysql_full_backup.sql → 打开方式 → 记事本;
  2. 左上角【文件】→【另存为】;
  3. 底部编码选择:UTF-8,保存覆盖原文件;
  4. 重新用 source 导入。

方案三:导出时加编码参数,重新备份(当前文件损坏时)

mysqldump -u root -p --all-databases --routines --triggers --events --single-transaction --default-character-set=utf8mb4 > D:\mysql_full_backup.sql

额外避坑点

  1. SQL 文件不要放在桌面、中文文件夹(如 E:\数据库备份\xxx.sql),纯英文路径;
  2. 拷贝文件用 U 盘 / 压缩包,不要微信 / QQ 传输,容易损坏字符;
  3. 5.7 数据库不要混用记事本默认 ANSI 编码保存备份,极易出现引号解析报错。

补充:如果 source 还是报单引号错误

打开 sql 文件,跳到报错第 4019 行,查看该行是否有乱码、残缺引号,大概率是传输过程文件截断损坏,只能重新完整导出一份备份。

=================================

如何在不打开文件的情况下,知道一个文本文件的字符编码类型?

图片

下面方案可行,可用

方案 1:命令行导入强制指定字符集(最优先,替代之前普通 cmd 导入)

进入 MySQL 5.7 bin 目录,执行这条完整命令,必须加 --default-character-set=utf8

mysql -u root -p --default-character-set=utf8 < E:\temp.sql

原理:强制客户端用 utf8 读取文件,不会把转义单引号 \' 解析成非法命令。