しばらくしてから、シェルスクリプトからMySQLクエリを実行したかったのです。私はスクリプトを書いたが、出力は期待通りではない。同じ値を再度データベースから出力しています。誰かが助けてくれますか?ある時間間隔の後にシェルスクリプトからMySQLクエリを呼び出す
$ ./demo.sh
Shell Script to Query a Database!
--Querying from the Database starts--
mysql: [Warning] Using a password on the command line interface can be insecure.
id
282
Wait for 2 seconds for the next ID.
mysql: [Warning] Using a password on the command line interface can be insecure.
id
282
Wait for 2 seconds for the next ID.
mysql: [Warning] Using a password on the command line interface can be insecure.
id
282
Wait for 2 seconds for the next ID.
mysql: [Warning] Using a password on the command line interface can be insecure.
id
282
Wait for 2 seconds for the next ID.
mysql: [Warning] Using a password on the command line interface can be insecure.
id
282
Wait for 2 seconds for the next ID.
--Query Stopped!--
SCRIPT- demo.sh
#!/bin/bash
echo "Shell Script to Query a Database!"
echo "--Querying from the Database starts--"
cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"
for i in {1..5};
do
./mysql -u root [email protected] << EOF
use catalyst_latest;
select id from ci_master limit 1;
EOF
echo "Wait for 2 seconds for the next ID."
sleep 2;
done
echo "--Query Stopped!--"
OUTPUTあなたは282が毎回返さなっていることがわかりますか?だから私は2秒後にデータベースから次のIDを欲しい。それをどうやるか教えてください。 ありがとうございます。
@アレクサンダーありがとうございます。私はこのようなことをしました - –