I am exporting a MySQL database on a windows machine (running XAMPP) to then import into a Linux server (using cmdline or phpMyAdmin IMPORT "filename.sql")
The dbdump file has mixed LF/CRLF line endings, and I know Linux uses LF for line endings.
Will this cause a problem?
Thanks
3
Answers
MySQL’s SQL tokenizer skips all whitespace characters, according to
ctype.h
.https://github.com/mysql/mysql-server/blob/8.0/mysys/sql_chars.cc#L94-L95
The
my_isspace()
function tests that in character setcs
, the characteri
is whitespace. For example in ASCII, this includes:All of the whitespace characters are considered the same for this purpose. So there’s no problem using CRLF or LF for line endings in SQL code.
But if your data (i.e. string values) contain different line endings, those line endings will not be converted.
I anticipate that the
mysql
program on each platform would expect "its" line-ending style. I honestly don’t know if, on each platform, it is "smart enough" to know what to do with each kind of file. (Come to think of it, maybe it does …) Well, there’s one sure way to find out …You say that the file has mixed(?!) line-endings? That’s very atypical …
However, there are ready-made [Unix/Linux] utilities,
dos2unix
andunix2dos
, which can handle this problem – and I’m quite sure that Windows has them too. Simply run your dump-file through the appropriate one before using it.you can import db from Windows to Linux without problem.