In other words, they tell the computer that you want to move the reading position to the start of the next line. If you've seen or used an old typewriter, you will know that these are separate actions, i.e. return slides the carriage horizontally so the typing position is at the start of the current line, and line-feed moves the paper up a bit so you are typing on an empty line. Of course, the typewriter also allows you to combine these in a single action in normal use.
Different operating systems represent these special newline indicators in different ways, so the data-load code you found is telling MySQL how to recognise the new line as \r\n in a text file on Windows. Unix combines them both as \n, a bit like the combined action on the typewriter.
Puspender Tanwar wrote:means, \r\n is used for pointing the cursor to the starting of new line ?
Essentially, yes. But in this case you do not have a cursor on a screen, because you are reading a stream of characters from a file. In this example, the text within the file is presumably structured as a series of lines, so you need to know when the current "line" of incoming characters ends and the new one begins. If the file was in a binary format e.g. an image, it would not contain text "lines" at all.
Puspender Tanwar wrote:don't we do this using \n in windows ?
I don't do much of this kind of thing on Windows, but it probably depends on how the text file was created e.g. if the file came from Unix originally then it may only have "\n" or it may have been converted to use "\r\n" for Windows. When you move files between Windows and Unix, this is one of the things that can cause problems. Also, different tools may be able to handle this for you automatically if they know which OS they are running on. In this case it looks like you need to tell MySQL explicitly how to recognise the end of a "line" in the incoming stream of data.
Puspender Tanwar wrote:and what this whole statement means LINES TERMINATED BY '\r\n';
This means exactly what it says:
Load some data...
.. from a local input file called '/path/pet.txt'...
... into a table called 'pet'...
... and each incoming line ends with '\r\n'.
This file is probably in CSV format, which is commonly used for tabular data in flat files, although it's not explicitly stated here.