Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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

share|improve this answer
1  
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. bugs.mysql.com/bug.php?id=62578 –  maristgeek Feb 28 at 0: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. apple.stackexchange.com/questions/95127/… –  maristgeek Feb 28 at 0:20
    
Nice catch. "tmux" also does everything screen does, and more. –  quadruplebucky Feb 28 at 0:55
    
Thanks @John. I eventually used byobu, so your advise helped a lot! –  valk Mar 1 at 19:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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