Skip to main content
added 38 characters in body
Source Link
muru
  • 78.4k
  • 16
  • 214
  • 320

Please help if possible.

a file.txt have a multipe sql update.

update table1 set meta_url = replace(meta_url,'test1.jpg','test1.gif'); update table1 set meta_url = replace(meta_url,'test2.jpg','test2.gif'); update table1 set meta_url = replace(meta_url,'test3.jpg','test3.gif'); update table1 set meta_url = replace(meta_url,'test4.jpg','test4.gif'); update table1 set meta_url = replace(meta_url,'test5.jpg','test5.gif'); ... update table1 set meta_url = replace(meta_url,'test100.jpg','test100.gif'); 

I want to create a script which allows to connect automatic, and execute all lines in file.txt at time.

the concept like that:

mysql -u root -p ( user and password log automatic by script)

use databasename1;

update all line in file.txt

exit;

service mysql restart

mysql -u root -p ( user and password log automatic by script) use databasename1; update all line in file.txt exit; service mysql restart 

Please help if possible.

a file.txt have a multipe sql update.

update table1 set meta_url = replace(meta_url,'test1.jpg','test1.gif'); update table1 set meta_url = replace(meta_url,'test2.jpg','test2.gif'); update table1 set meta_url = replace(meta_url,'test3.jpg','test3.gif'); update table1 set meta_url = replace(meta_url,'test4.jpg','test4.gif'); update table1 set meta_url = replace(meta_url,'test5.jpg','test5.gif'); ... update table1 set meta_url = replace(meta_url,'test100.jpg','test100.gif'); 

I want to create a script which allows to connect automatic, and execute all lines in file.txt at time.

the concept like that:

mysql -u root -p ( user and password log automatic by script)

use databasename1;

update all line in file.txt

exit;

service mysql restart

a file.txt have a multipe sql update.

update table1 set meta_url = replace(meta_url,'test1.jpg','test1.gif'); update table1 set meta_url = replace(meta_url,'test2.jpg','test2.gif'); update table1 set meta_url = replace(meta_url,'test3.jpg','test3.gif'); update table1 set meta_url = replace(meta_url,'test4.jpg','test4.gif'); update table1 set meta_url = replace(meta_url,'test5.jpg','test5.gif'); ... update table1 set meta_url = replace(meta_url,'test100.jpg','test100.gif'); 

I want to create a script which allows to connect automatic, and execute all lines in file.txt at time.

the concept like that:

mysql -u root -p ( user and password log automatic by script) use databasename1; update all line in file.txt exit; service mysql restart 
Source Link
amine
  • 23
  • 6

How to run multiple line sql from text file

Please help if possible.

a file.txt have a multipe sql update.

update table1 set meta_url = replace(meta_url,'test1.jpg','test1.gif'); update table1 set meta_url = replace(meta_url,'test2.jpg','test2.gif'); update table1 set meta_url = replace(meta_url,'test3.jpg','test3.gif'); update table1 set meta_url = replace(meta_url,'test4.jpg','test4.gif'); update table1 set meta_url = replace(meta_url,'test5.jpg','test5.gif'); ... update table1 set meta_url = replace(meta_url,'test100.jpg','test100.gif'); 

I want to create a script which allows to connect automatic, and execute all lines in file.txt at time.

the concept like that:

mysql -u root -p ( user and password log automatic by script)

use databasename1;

update all line in file.txt

exit;

service mysql restart