Quantcast
Viewing all articles
Browse latest Browse all 812

how to run mysql script on the background (no replies)

Hi,

I have a sql script to select some information, called query.sql:

vi query.sql:
select * into outfile '/tmp/testing_20100624.txt'
from external_entities oee where oee.name in ( Select ee.name from
external_entities ee group by ee.name having count(*) >1);

I want to run it as backup on Unix, but it terminated my output file

I did:

tpstgdbr-mysql[3]% mysql -u root -p --database testing < query.sql &
[1] 13978

but as soon as I hit enter I received :
tpstgdbr-mysql[4]%
[1] + Stopped (tty output) mysql -u root -p --database testing < query.sql
tpstgdbr-mysql[4]%

the process is still running
tpstgdbr-mysql[5]% ps -ef|grep mysql

mysql 13978 13972 0 12:50:44 pts/6 0:00 mysql -u root -p --database testing

I checked the output file from /tmp and nothing generated
tpstgdbr-mysql[6]% cd /tmp
tpstgdbr-mysql[7]% ls -ltr testing_20100624

but if I run the sql script on mysql command then the output was generated...

tpstgdbr-mysql[17]% mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 49900
Server version: 5.1.41-enterprise-gpl-pro-log MySQL Enterprise Server - Pro Edition (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use testing;
Database changed
mysql> source query.sql

tpstgdbr-mysql[37]% ls -ltr /tmp/testing*
-rw-rw-rw- 1 mysql mysql 0 Jun 24 14:13 testing_20100624.txt


The problem is, this syntax will take quiet long and the server is going to kick me out every 1hr and my process will be terminated.

Why I can't execuse the sql script run on the background?

thanks,

BN

Viewing all articles
Browse latest Browse all 812

Trending Articles