snk Posted September 3, 2008 Share Posted September 3, 2008 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted September 3, 2008 Share Posted September 3, 2008 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. What help screen? Quote Link to comment Share on other sites More sharing options...
snk Posted September 3, 2008 Author Share Posted September 3, 2008 thank you for your reply, the help screen that shows some basic syntax when you enter mysql wrong_command or mysql --help Quote Link to comment Share on other sites More sharing options...
corbin Posted September 3, 2008 Share Posted September 3, 2008 Would mysqlimport work? Quote Link to comment Share on other sites More sharing options...
fenway Posted September 3, 2008 Share Posted September 3, 2008 thank you for your reply, the help screen that shows some basic syntax when you enter mysql wrong_command or mysql --help Did you try just connecting with the user & pass? Quote Link to comment Share on other sites More sharing options...
snk Posted September 3, 2008 Author Share Posted September 3, 2008 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. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 3, 2008 Share Posted September 3, 2008 If you have INSERT statement, you basicallly have to run the SQL commands... but it shouldn't make any difference if you have "ssh" or "shellscript" or "modes". Quote Link to comment Share on other sites More sharing options...
snk Posted September 3, 2008 Author Share Posted September 3, 2008 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. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 4, 2008 Share Posted September 4, 2008 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. Quote Link to comment Share on other sites More sharing options...
snk Posted September 5, 2008 Author Share Posted September 5, 2008 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted September 5, 2008 Share Posted September 5, 2008 I simply meant the style of using "--optionname=optionval", vs. "-o optionVal". Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.