A
A
Alexey Nikolaev2015-09-23 14:43:26
MySQL
Alexey Nikolaev, 2015-09-23 14:43:26

Is there a way to import a DB with data errors resulting in syntax errors?

Good afternoon!
There is a DB, 900 megabytes and hundreds of thousands of lines. Export passes normally, but at import in other DB the heap of syntax errors falls out. The data in it is generally very crooked, therefore, all sorts of double quotes and other troubles occur.
Usually I went through the dump with pens and ruled everything there. It worked when the database weighed 10-20 megabytes. In this case, this is impossible, but you need to import the database. How to be?
I would be grateful for advice, thanks.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Ruslan Fedoseev, 2015-09-23
@Heian

mysqldump > file.sql

M
Max, 2015-09-23
@MaxDukov

play with
fields-escaped-by
fields-optionally-enclosed-by
fields-enclosed-by

G
Gregory, 2015-09-23
@grigruss

<?php
$sql=file_get_contents("dump.sql");
file_put_contents("new_dump.sql",htmlspecialchars($sql,ENT_QUOTES));
?>

htmlspecialchars()
str_replace()

R
Roman Mirilaczvili, 2015-09-23
@2ord

You need to escape quotes and other special characters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question