We help IT Professionals succeed at work.

Load .sql file into mysql through php

infodigger
infodigger asked
on
Hello,

I have a .sql file which contains a few queries and I need to load it into mysql. I tried two things, none of them worked:

1. Use file_get_contents and load the contents of the file into a php string and then use mysql_query to load them to the database. This didn't work at all.

2. Use load data command from mysql. This didn't work because I am on a shared hosting environment and I can't grand file access to the mysql user.

Is there any other alternative?

Thanks!
Comment
Watch Question

Commented:
Have you tried "mysqli_multi_query()" function?

Author

Commented:
Thank you very much! It worked perfectly!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.