Page 1 of 1

How to import a .SQL file when a specific user creates a database?

Posted: Thu Apr 19, 2018 6:25 pm
by lucasbustamante
I'm building one of those free trial SaaS, I have managed to create a database programatically with Vesta's API command v-add-database, but now I would like to automatically import a .SQL file into it.

To import the SQL file when a database is created, I'm using a PHP script that read a file and queries line by line, but it's taking an average 90~100 seconds to process the entire default database, which has around 5k lines.

I feel like I could achieve this with a bash script, but I suck at Linux. Can someone give me a sample of such script?