Is it possible to transfer flat file to MySQL database?
I have some flat file like this:
And I would like to transfer it all to MySQL since file has grown to 8 MB
Do you now for any script that does all the job?
You could use the mysqlimport utility to read in a flat file. Using one of the options to the import utility, you can specify a string that delimits your fields:
mysqlimport -u user -ppassword --fields-terminated-by='::' dbname flatfile.txt
Or you could write a quick perl script that dumps your flatfile into INSERT statements, then feed that file into the mysql utility with the stdin redirect:
mysql -u user -ppassword dbname < sqlstuff.txt
You have to make sure that the database exists in MySQL before you use either of those methods. If you use the INSERT statement file, you could define your database before the INSERT statements.
[This message has been edited by donarb (edited June 02, 2000).]