1

I need to import a very large MySQL table on remote server. Usually I'm using

mysql -u mysql_user -pMypass db_name < sql_data.sql

But it takes about 5 hours to complete the task. I tried using nohup but the logout process is killing the import. I found that I could use screen, but without any luck.

screen -dmS import_table mysql -u mysql_user -pMypass db_name < sql_data.sql

Please suggest what else I can try. Thanks.

valk
  • 477
  • 2
  • 8
  • 20

1 Answers1

2

Simply invoke screen at a shell prompt. After it's started the shell inside screen, then run the mysql import command as normal. To detach from the screen session, type Ctrl-A, D. To reattach the session, type screen -r

John
  • 8,920
  • 1
  • 28
  • 34
  • 2
    It's not as simple as that, mysql commands for many version do not do well with window resizing (like what happens when dettaching a screen) so the process stops with SIGWINCH. http://bugs.mysql.com/bug.php?id=62578 – maristgeek Feb 28 '14 at 00:18
  • 1
    As odd as it sounds in another shell before detaching screen you can try `killall -WINCH mysql` and then detach your screen session. http://apple.stackexchange.com/questions/95127/problems-with-resizing-terminal – maristgeek Feb 28 '14 at 00:20
  • Nice catch. "tmux" also does everything screen does, and more. – quadruplebucky Feb 28 '14 at 00:55
  • Thanks @John. I eventually used byobu, so your advise helped a lot! – valk Mar 01 '14 at 19:49