Forum Moderators: open

Message Too Old, No Replies

CronJob and MySql updates

         

ulk26

9:48 am on Dec 2, 2009 (gmt 0)

10+ Year Member



Hi, I run a forum and need to run some updates to the mysql database every 24 hours via a cron job.

Here is my SQL Update query

update members set ID_GROUP="12" where ID_group="0"

so i want to put this in a file called update-group.sql

but not sure on the formate of the sql file.

i would like the sql file to contain the login info for the database aswell

can anyone help?

phranque

12:22 pm on Dec 7, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld [webmasterworld.com], ulk26!

you can't put the login information in the sql file.
it is provided in the command line:

mysql -uusername -ppassword databasename <update-group.sql

ulk26

12:27 pm on Dec 7, 2009 (gmt 0)

10+ Year Member



Thanks for the reply, what format do i need to put in the sql file

or is it a case of just putting in my update query?

phranque

3:08 pm on Dec 7, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



yes you simply put the sql statements in the .sql file and use stdin or pipe it into your mwsql command.

ulk26

3:25 pm on Dec 7, 2009 (gmt 0)

10+ Year Member



ok thanks