1

I've created a database in the remote machine. Currently, the database is empty and I need to import using a backup(.sql) file. The backup file is in my local machine, it is a 40gb file. And the remote machine has an empty space of about 45gb.

So, if I try to upload the backup file into the remote machine, then it will be impossible to import into the database(remote machine will be running out of space). The only possible solution looks like, pointing the server to use the location of the local machine's backup file and to import. Is there any command to work on this?

I have tried the following commands

bash > mysql -h hostname -u user -pPassword databasename < /Users/path/to/file/backup.sql > update.log

But, it returns an error saying

bash: no such file or directory. 

I'm sure the file is present within my local machine.

Does any one have any idea on how to import sql file. Or is there any alternate ways to do this?

Local machine is running on OS X Remote machine is SUN OS. I'm using SSH to connect with remote machine.

1

Alternative approach, but the one you tried is also right and should work:

cat /Users/path/to/file/backup.sql | mysql -h hostname -u user -pPassword -D databasename > update.log

Just in case, do you have mysql-client installed on your local machine?

  • cat command is used to read the file right?? Yes i have mysql-client installed in my local machine – GIRI Apr 7 '15 at 14:34
  • The cat is not necessary ( < /Users/path/to/file/backup.sql mysql ..... – Anthon Apr 7 '15 at 14:51
  • @Anthon, So what does this command actually do? Is it going to open our local mysql and later connecting to server database? – GIRI Apr 7 '15 at 19:37
  • I tried to execute the command it says, cannot connect to MYSQL server on 'hostname' – GIRI Apr 7 '15 at 19:48
  • @GIRI I never used MySQL, I just noticed that in the command sequence baggy provided that the cat was not necessary. – Anthon Apr 8 '15 at 3:43
-1

You have to run that command in the machine where the file exists. Not on the MySQL Server. Alternatively copy it to the MySQL server and run.

  • Ya, I'm running it in my machine (not on mysql server). As the sql file is a huge file and server will be running out of space if I copy and import it. – GIRI Apr 6 '15 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.