Jump to content

login and insert dump file in one command


Recommended Posts

Hello,

 

I dont have ssh access to my hosting account but i can run commands via shellscript, it is quite convenient as i can upload zipped files or to delete folders and files very easy.

 

I would like to insert a dump file with one command. Im trying to run mysql -u user -p pass database_name < file.sql but i see the help screen.

 

is there any idea or php script that imports my sql file?

 

I have tried with phpmyadmin but it doesnt work as dump file is big, about 20mb

 

thank you in advance

 

thank you for your replies,

 

The problem is that I dont have any ssh but a shellscript, I can execute commands but i can't be inside of any mode, such as ftp, mysql, etc. I have to trigger just one command. I dont know if its possible to do it via php script, I think there should be something coz joomla, wordpress and other scripts can insert the database file during installation process.

 

Thanks for your consideration.

doesnt work like that. for example, if write

 

> cd folder/folder2/folder3

 

then I write

 

> ls

 

I will see content of the folder that shellscript resides, instead of folder3

 

in order to see content of folder3 I have to write

 

> ls folder/folder2/folder3

 

thus I am asking for one command execution. of course I wouldnt mind if I can insert a dump file via php, but I dont know how to do it.

 

Thanks.

 

 

Just looking over your command again:

 

mysql -u user -p pass database_name < file.sql

 

There shouldn't be a space between -p and pass; or you can use --password=pass.  But typing the password in plaintext like that isn't secure -- see here.

 

That will probably fix it... but I'd specify the full path to the .sql file just to be sure.

 

Personally, I prefer the --user=user_name --password=pass --database=dbname format.

 

You can also redirect the output to a text file so that you can see what's going on.

hello again,

 

thanks for your help so far...

 

fenway, what do you mean by database format? like charset or file format.. or storage engine like myisam etc ?

 

I was looking on the net and i couldnt find a useful text, I would appreciate if you could provide one for me.

 

cheers

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.