nohup
should work for you, what was your exact command? Maybe you're missing something. Here's section from wikipedia about it:
Nohupping backgrounded jobs is typically used to avoid terminating them when logging
off from a remote SSH session. A different issue that often arises in this situation
is that ssh is refusing to log off ("hangs"), since it refuses to lose any data
from/to the background job(s). This problem can also be overcome by redirecting all
three I/O streams:
nohup ./myprogram > foo.out 2> foo.err < /dev/null &
So you could do something like:
ssh -n -f user@remotebox "sh -c 'cd /foo/bar; nohup ./myprogram > foo.out 2> foo.err < /dev/null &'"
Or if that still doesn't work, you can try screen
. It will allow you to run your process in the "background", and it will keep running after you logout.
First, ssh
over to the remote box, then from there use screen
and start your process, and you can give your screen
a session name if you want. You won't really notice anything different, but start your process in that session. You can than exit out of the screen
session by using the command Ctrl-a d
. It will look something like this:
user@remotebox:~$ screen -S foobarsession
user@remotebox:~$ startmyprocess
[detached from 4865.foobarsession]
user@remotebox:~$
You can then exit out of your ssh session, and the process will keep running. To reconnect to the screen
session later on, ssh back to the remote box and use screen -r
to reconnect. You can use screen -ls
to list the sessions.
user@remotebox:~$ screen -ls
There is a screen on:
4865.foobarsession (10/05/2012 11:10:57 AM) (Detached)
1 Socket in /var/run/screen/S-user
user@remotebox:~$ screen -r foobarsession
user@remotebox:~$ screen -ls
4865.foobarsession (10/05/2012 11:10:57 AM) (Attached)
1 Socket in /var/run/screen/S-user
user@remotebox:~$
Make sure that you installed MySQL as root sudo apt-get install mysql-server
. This should usually work.
To carry on from what you have here. You can create the missing directories but make sure they are owned by user\group mysql: chown -R mysql:mysql /var/lib/mysql
If you would like to change MySQL's data directory, do so in MySQL's configuration file /etc/mysql/my.cnf
Then you can chose between configuring apparmor to allow MySQL to read\execute\modify the new data directory and sub directories or, at your very own risk, you can remove apparmor. You may need to be root
to do the following:
/etc/init.d/apparmor stop
/etc/init.d/apparmor teardown
update-rc.d -f apparmor remove
apt-get purge apparmor
reboot
Then you can run mysql_install_db
.
But then you will have no users in the database ! To solve this:
mysqld --skip-grant-tables --skip-networking & #Start MySQL manually with no authentication checks
mysql # Access MySQL, no username\password needed
use mysql;
DELETE FROM user;
INSERT INTO `user` (`Host`, `User`, `Password`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`) VALUES('localhost','root',PASSWORD('root'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','','0','0','0','0'); #Add root user with passowrd, root
FLUSH PRIVILEGES;
GRANT ALL ON *.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
exit;
killall mysqld;
start mysql
mysql -u root -p
# Enter password, which is: root
Best Answer
Example: