I have a bash script that installs mysql for me.One line, that executes mysqld_safe, makes the script to hang - it won't continue to the following code.Obviously there's ampersand at line's end, but it won't help, see:root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# /usr/local/mysql/bin/mysqld_safe --skip-networking --skip-grant-tables --user=mysql --basedir=/usr/local/mysql --ledir=/usr/local/mysql/libexec &[1] 20131root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# 130531 17:45:54 mysqld_safe Logging to '/usr/local/mysql/var/dor-desktop.err'.130531 17:45:54 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var^Croot@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# You can see that only CTRL+C helps to exit, but it exits my entire bash script...I've also tried using nohup, still didn't help, see:root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# nohup /usr/local/mysql/bin/mysqld_safe --skip-networking --skip-grant-tables --user=mysql --basedir=/usr/local/mysql --ledir=/usr/local/mysql/libexec &[1] 19751root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# nohup: ignoring input and appending output to `nohup.out'^C[1]+  Exit 1                  nohup /usr/local/mysql/bin/mysqld_safe --skip-networking --skip-grant-tables --user=mysql --basedir=/usr/local/mysql --ledir=/usr/local/mysql/libexecroot@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install# Any idea how to force mysqld_safe to run in background?Edit (May 31, 16:37 UTC):The error log, '/usr/local/mysql/var/dor-desktop.err':130531 18:03:55 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var130531 18:03:55 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.130531 18:03:55 [Note] Plugin 'FEDERATED' is disabled.130531 18:03:55  InnoDB: Initializing buffer pool, size = 8.0M130531 18:03:55  InnoDB: Completed initialization of buffer poolInnoDB: The first specified data file ./ibdata1 did not exist:InnoDB: a new database to be created!130531 18:03:55  InnoDB: Setting file ./ibdata1 size to 10 MBInnoDB: Database physically writes the file full: wait...130531 18:03:56  InnoDB: Log file ./ib_logfile0 did not exist: new to be createdInnoDB: Setting log file ./ib_logfile0 size to 5 MBInnoDB: Database physically writes the file full: wait...130531 18:03:56  InnoDB: Log file ./ib_logfile1 did not exist: new to be createdInnoDB: Setting log file ./ib_logfile1 size to 5 MBInnoDB: Database physically writes the file full: wait...InnoDB: Doublewrite buffer not found: creating newInnoDB: Doublewrite buffer createdInnoDB: Creating foreign key constraint system tablesInnoDB: Foreign key constraint system tables created130531 18:03:56  InnoDB: Started; log sequence number 0 0130531 18:03:56 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.Version: '5.1.57-log'  socket: '/usr/local/mysql/mysql.sock'  port: 3306  Source distribution130531 18:08:41 mysqld_safe mysqld from pid file /usr/local/mysql/var/dor-desktop.pid ended130531 18:17:09 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var130531 18:17:09 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.130531 18:17:09 [Note] Plugin 'FEDERATED' is disabled.130531 18:17:09  InnoDB: Initializing buffer pool, size = 8.0M130531 18:17:09  InnoDB: Completed initialization of buffer poolInnoDB: The log sequence number in ibdata files does not matchInnoDB: the log sequence number in the ib_logfiles!130531 18:17:09  InnoDB: Database was not shut down normally!InnoDB: Starting crash recovery.InnoDB: Reading tablespace information from the .ibd files...InnoDB: Restoring possible half-written data pages from the doublewriteInnoDB: buffer...130531 18:17:09  InnoDB: Started; log sequence number 0 44233130531 18:17:09 [Note] Recovering after a crash using mysql-bin130531 18:17:09 [Note] Starting crash recovery...130531 18:17:09 [Note] Crash recovery finished.130531 18:17:09 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.Version: '5.1.57-log'  socket: '/usr/local/mysql/mysql.sock'  port: 3306  Source distribution130531 18:21:14 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var130531 18:21:14 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.130531 18:21:14 [Note] Plugin 'FEDERATED' is disabled.130531 18:21:14  InnoDB: Initializing buffer pool, size = 8.0M130531 18:21:14  InnoDB: Completed initialization of buffer poolInnoDB: The log sequence number in ibdata files does not matchInnoDB: the log sequence number in the ib_logfiles!130531 18:21:14  InnoDB: Database was not shut down normally!InnoDB: Starting crash recovery.InnoDB: Reading tablespace information from the .ibd files...InnoDB: Restoring possible half-written data pages from the doublewriteInnoDB: buffer...130531 18:21:14  InnoDB: Started; log sequence number 0 44233130531 18:21:14 [Note] Recovering after a crash using mysql-bin130531 18:21:14 [Note] Starting crash recovery...130531 18:21:14 [Note] Crash recovery finished.130531 18:21:14 [Note] /usr/local/mysql/libexec/mysqld: ready for connections.Version: '5.1.57-log'  socket: '/usr/local/mysql/mysql.sock'  port: 3306  Source distributionEdit #2 (May 31, 16:46 UTC):Sorry! I forgot to add that immediately after executing mysqld_safe, there's a wait  command.The wait command exists in order to make sure that the daemon has started, so that I'd be able to execute mysql -u root.Please wait, perhaps I'll find a solution.
Run mysqld_safe in background
bash;software installation;mysql
OK I got to a solution:# Wait for the mysqld_safe process to startwhile ! [[ $mysqld_process_pid =~ ^[0-9]+$ ]]; do  mysqld_process_pid=$(echo $(ps -C mysqld -o pid=) | sed -e 's/^ *//g' -e 's/ *$//g')  sleep 1doneExplanation:The wait command that was executed immediately after executing mysqld_safe, was waiting for mysqld_safe (which is obvious), but I needed it to wait for mysqld which is initiated by the user mysql! The process mysqld_safe would never change it's state (it's in a never-ending loop), therefore the wait command waits forever!So I wrote a code that waits for mysqld process to start.