나를 위해 mysql을 설치하는 bash 스크립트가 있습니다.
실행된 줄로 인해 mysqld_safe
스크립트가 중단되고 다음 코드가 계속 실행되지 않습니다.
분명히 줄 끝에 앰퍼샌드가 있지만 도움이 되지 않습니다. 다음을 참조하세요.
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] 20131
root@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
^C
root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install#
이는 종료에만 도움이 된다는 것을 알 수 있지만 CTRL+C
전체 bash 스크립트를 종료합니다...
나는 또한 사용해 보았지만 nohup
여전히 도움이 되지 않았습니다. 다음을 참조하십시오.
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] 19751
root@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/libexec
root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install#
mysqld_safe
백그라운드에서 강제로 실행하는 방법을 아시나요 ?
편집자 (5월 31일 16:37 UTC):
오류 기록, '/usr/local/mysql/var/dor-desktop.err'
:
130531 18:03:55 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
130531 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.0M
130531 18:03:55 InnoDB: Completed initialization of buffer pool
InnoDB: 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 MB
InnoDB: Database physically writes the file full: wait...
130531 18:03:56 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
130531 18:03:56 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
130531 18:03:56 InnoDB: Started; log sequence number 0 0
130531 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 distribution
130531 18:08:41 mysqld_safe mysqld from pid file /usr/local/mysql/var/dor-desktop.pid ended
130531 18:17:09 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
130531 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.0M
130531 18:17:09 InnoDB: Completed initialization of buffer pool
InnoDB: The log sequence number in ibdata files does not match
InnoDB: 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 doublewrite
InnoDB: buffer...
130531 18:17:09 InnoDB: Started; log sequence number 0 44233
130531 18:17:09 [Note] Recovering after a crash using mysql-bin
130531 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 distribution
130531 18:21:14 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
130531 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.0M
130531 18:21:14 InnoDB: Completed initialization of buffer pool
InnoDB: The log sequence number in ibdata files does not match
InnoDB: 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 doublewrite
InnoDB: buffer...
130531 18:21:14 InnoDB: Started; log sequence number 0 44233
130531 18:21:14 [Note] Recovering after a crash using mysql-bin
130531 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 distribution
편집 #2(5월 31일 16:46 UTC):
죄송합니다!wait
실행 직후 mysqld_safe 명령이 있다는 사실을 추가하는 것을 잊어버렸습니다 . 이 wait
명령은 데몬을 실행할 수 있도록 시작되었는지 확인하기 위해 존재합니다 mysql -u root
. 잠시 기다려 주시면 해결책을 찾을 수 있을 것입니다.
답변1
좋아, 해결책을 찾았습니다.
# Wait for the mysqld_safe process to start
while ! [[ "$mysqld_process_pid" =~ ^[0-9]+$ ]]; do
mysqld_process_pid=$(echo "$(ps -C mysqld -o pid=)" | sed -e 's/^ *//g' -e 's/ *$//g')
sleep 1
done
설명: 실행 직후에 실행된 wait 명령이 mysqld_safe
대기 중이지만 (이것은 명백합니다) 사용자가 시작한 명령을 mysqld_safe
기다려야 합니다 ! 프로세스는 자신의 상태를 절대 변경하지 않으므로(무한 루프에 있음) 명령이 영원히 기다립니다!mysqld
mysql
mysqld_safe
wait
mysqld
그래서 프로세스가 시작되기를 기다리는 코드를 작성했습니다 .
답변2
데이터베이스가 손상된 것 같습니다. 다음에 무엇을 해야 할지 알아보려면 dba.stackexchange.com에서 그의 게시물을 확인하겠습니다. 이는 스크립트와 관련이 없는 데이터베이스 문제인 것 같습니다.