Import multiple SQL scripts


#1

Hello!

I have a question to do.

I have a free account on 000webhost.
How can I import multiple SQL script files in PhpMyAdmin?
I have the database definition, records to insert and stored procedures to create in those scripts for my MariaDB database.

I’ll stay tuned to your comments.
Greetings!


#2

Hello open phpmyadmin and open the database in which you want to import data then click on import and choose your desired .sql.zip file image


#3

Ok, but I have to put all the scripts inside the zip file? If this is the case, in what folder, name and file format I have to put all of them?


#4

The file format should be .sql or .sql.gz


#5

So, if I have multiple scripts with names like:
script-1.sql
script-2.sql
script-3.sql

script-n.sql
I have to put them all into a zip file that it may be named, for example, like:
scripts.sql.zip

Is this correct?


#6

Nope, just drag/drop them onto the phpMyAdmin dashboard :slight_smile:


#7

You have to import them one by one


#8

That is precisely what I wanna avoid at all costs!
I have a total of 116 SQL scripts, the most of them are the SP’s that I have to use for my database, each one in a different script, and I have to use all of them.
Is there really no other way to make this massive upload of files in PhpMyAdmin?


#9

I imagine you could do it in PHP. May we see a cut-down sample of one of the SQL files? Is it a set of SQL statements that are semi-colon separated?

This script looks like it would work. It uses the multi_query method in the MySQLi connector, which will save you the bother of writing PHP to parse your SQL into lines.

How long do they normally take to import? Try triggering your import script over the web to start with, but if this times out because the files are large, you might be able to do something with cron. Depends on whether you overflow the permitted storage size in MySQL for free accounts, I guess :smile:.


#10

Well, I guess I can try this solution of PHP multi:query. I would it in these days and tell you how it goes.
Thanks for your help! :+1:


#11

Here you can do one thing.
You have to do it in your PC.
Open CMD and open your .sql files content folder and run this command

copy /b *.sql all_files.sql

This will concatenate all .sql files in a one file so you can import it at once. Make sure to make a backup of these .sql files


#12

Yes, I checked that solution too but If I’ll do that, I have to copy the files content in an established order (I mean, database definition file -> insert demo values file -> stored procedures definition files).

In this sense, what I can do is create a Windows batch file to execute this command with all those parameters and generate this final SQL file more quickly.

Thanks you. I will try this solution before the PHP multi_query and I will tell you how it goes.:+1:


Black Friday Sale 90% OFF
0
DAYS
0
HOURS
0
MINUTES
0
SECONDS
×