Importing an SQL statement file into MySQL
February 22nd, 2006
Here is a way to import a SQL file that contains statements into MySQL:
mysql –user=youruser –password=yourpassword –database=yourdbname < yourscript.scr
This is excellent when you have let’s say 100,000 records, and you want to import them as INSERT statements, but the SQL file is like 20MB’s! All you need to do is:
1) Optional: Compress your SQL file with gzip, it’s only text, so it will be MUCH smaller
2) Upload it to your server
3) Login through SSH
4) Navigate to the directory where you uploaded the gzipped file
5) Use gunzip to uncompress it
6) Use the mysql command line I gave at the beginning, and use your script file instead of yourscript.scr
