I was importing a confirmed UTF-8 encoded SQL database into Sequel Pro on Mac and got thrown this error halfway through:
An error occurred when reading the file, as it could not be read in the encoding you selected (Autodetect - Unicode (UTF-8)).
Only 1273 queries were executed.
Is this because the database file was originally from a windows machine and it's linebreaks stuffed things up?
I imagine I will get this error even if I tried to send the same database over file transfer to a server so how can I fix it's encoding?
-- MySQL dump 10.13 Distrib 5.5.40-36.1, for Linux (x86_64)
--
-- Host: localhost Database: *****
-- ------------------------------------------------------
-- Server version 5.5.40-36.1-log
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `******`
--
-
What text caused the problem?Rick James– Rick James2015年08月19日 17:37:16 +00:00Commented Aug 19, 2015 at 17:37
-
didn't say but my guess is a windows encoded line breaksmokerockspunchcops– smokerockspunchcops2015年08月19日 22:42:32 +00:00Commented Aug 19, 2015 at 22:42
-
Saving the file in notepad does have encoding option at the bottom.open the file in notepad on windows and save it as utf-8 format and then try loading it into MySQLNawaz Sohail– Nawaz Sohail2015年08月20日 00:33:57 +00:00Commented Aug 20, 2015 at 0:33
-
So the file isn't real utf-8? If I am on a mac I can do the same thing with it's default text viewer to fix it?smokerockspunchcops– smokerockspunchcops2015年08月20日 01:11:22 +00:00Commented Aug 20, 2015 at 1:11
-
As Nawaz wrote above, open the file in a text editor (i used TextWrangler on Mac), and resave as utf-8 format.Jojje– Jojje2016年02月04日 11:41:24 +00:00Commented Feb 4, 2016 at 11:41
1 Answer 1
Based on this blog post
http://ilikekillnerds.com/2014/08/fixing-sequel-pro-sql-encoding-error-for-imported-sql-files/
When importing your database dump, you need to select Western (Mac OS Roman) as the encoding format for the file to import without issue.
-
2Does anyone know why this works? I would really like to know what problem existed with UTF-8 (or what problem with Windows), that did not let me import originally.Douglas.Sesar– Douglas.Sesar2017年05月02日 13:00:08 +00:00Commented May 2, 2017 at 13:00
-
1Thanks, this also works for MySQL dumps that are generated on CentOS.Alex– Alex2017年07月09日 12:56:31 +00:00Commented Jul 9, 2017 at 12:56
-
I confirm this works on MacOS High Sierra 10.13.6. thanks @liangzanAhmad Mushtaq– Ahmad Mushtaq2018年11月13日 11:30:51 +00:00Commented Nov 13, 2018 at 11:30
-
This works with Sequel Pro (Nightly) on Mojave as wellUrs– Urs2019年06月19日 18:27:44 +00:00Commented Jun 19, 2019 at 18:27
-
1This worked correctly for a MySQL dump that originated on Linux / Mysql and needed to be imported over SSH to a MariaDB 10 database. Thanks.HongPong– HongPong2019年09月11日 14:41:12 +00:00Commented Sep 11, 2019 at 14:41