patternsqlMinor
Will a mysql db import be interrupted if my ssh session times out?
Viewed 0 times
mysqlwillsessiontimesinterruptedoutsshimport
Problem
I have a large-ish (several GB) mysql DB that I'm planning to import via
in a SSH session.
What would happen if my SSH connection drops?
Is it safer to run something like
Or does mysql not care?
Using the following
mysql -u root -p mydb < mydb.sqlin a SSH session.
What would happen if my SSH connection drops?
Is it safer to run something like
nohup mysql -u root -p mydb < mydb.sqlOr does mysql not care?
Using the following
- MySQL 5.1.45
- CentOS 5.x
Solution
If the SSH drops without putting the mysql session into the background (along with nohup), then the DB connection is at the SSH session's mercy. So, yes, mysql would care about the lifecycle of the SSH session.
You should launch it with
Then, you can walk away feeling OK (you could actually logout on purpose at this point) because process 1 (
You should launch it with
& at the end as follows:nohup mysql -u root -p mydb < mydb.sql &Then, you can walk away feeling OK (you could actually logout on purpose at this point) because process 1 (
init) will pick up the process ID that is running the mysql session upon the SSH session termination (voluntary or involuntary) because it was suddenly orphaned (What a great dad !!!).Code Snippets
nohup mysql -u root -p mydb < mydb.sql &Context
StackExchange Database Administrators Q#140565, answer score: 4
Revisions (0)
No revisions yet.