Importing a .CSV file in MySQL from command line.
When you want to import records from a .csv file into a table, follow the steps given below:[root@localhost]$ mysql -u [username] -p [password] [root@localhost]$ use [my_database] [root@localhost]$ LOAD DATA LOCAL INFILE ‘userinfo.csv’ INTO TABLE [table name] FIELDS TERMINATED BY ‘,’ LINES TERMINATED BY ‘\n’;
This should be the same command that get executed on windows command prompt as well.
Exporting a .CSV file based on user requirement is very easy in MySQL.
A simple query could generate your desired output as .CSV file. Let’s see what that command is[root@localhost]$ mysql -u [username] -p [password] [root@localhost]$ use [my_database] [root@localhost]$ SELECT * INTO OUTFILE ‘/userinfo.csv’ FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘”” ESCAPED BY ‘\\’ LINES TERMINATED BY ‘\n’ FROM Table_Users;
Voila! You have your desired results in as a .csv file.
In the next article, we will discuss on how we can import data from .csv file back into database.
Mysql Tips for Beginners
* How to log into Mysql from command prompt?
First, Go to the Mysql installation directory and move to the bin directory (C:\Mysql\bin\)
Execute the following command to log into Mysql
C:\Mysql\bin> mysql -u [username] -p [password]
You will be shown mysql command which indicates that you have successfully logged in
To shutdown mysql from command prompt, issue the following command in Linux box[root@computer /]# mysqladmin -u root -p shutdown
C:\mysql\bin> mysqladmin -u root -p shutdown _
Different browser modes
To ensure backward compatibility with older browsers, browser creators had different modes for sites that work for different browser specifications
* Standard mode in Browser:
Browser renders a page according to the specifications set
* Quirks mode in Browser:
Browser loosely renders the page and manipulates the box model differently which happens to be in sites built for IE 5.5 (and lesser versions) or Opera 7 browsers
* Almost standard mode in Browser:This is a mode in Firefox/Safari browsers where they handle the tables quite differently from standard mode Continue Reading…
What is CODEC and how does it work?
CoDec stands for Compressor/Decompressor which is related to media files and which enables them play videos & audios.
Size of the video or audio content would be very large without these codecs and it is for this very reason we use codecs to compress these media files to help enable transmission. When these files are played, they are then decompressed by these codec programs. Continue Reading…
301 redirect happens when a page has been moved/removed and is no longer available. When this happens, you can direct the user to the new page location and explicitly state for the crawlers that the page has been permanently moved to the new location Continue Reading…
Easy steps to play.avi file in a Linux box
Searching on google I came across this link initially but didn’t understand what it really did and so skipped the link. It was after searching for various other .avi files I came across this link again which made the mplayer installation an easier task. Continue Reading…