skip to Main Content

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


  1. 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

    else if (my_isspace(cs, i))
    state_map[i] = MY_LEX_SKIP;
    

    The my_isspace() function tests that in character set cs, the character i is whitespace. For example in ASCII, this includes:

    • space
    • tab
    • newline (n)
    • carriage return (r)
    • vertical tab (v)
    • form feed (f)

    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.

    Login or Signup to reply.
  2. 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 and unix2dos, 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.

    Login or Signup to reply.
  3. you can import db from Windows to Linux without problem.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search