how to run a my sql script with php

  • barry
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jan 28, 2005
  • Posts: 115
  • Loc: scotland
  • Status: Offline

Post January 30th, 2009, 5:07 am

hi all

I need to reinstall a mysql database on a regular basis. I have exported the database to a text file and I would like to use a simple php script to reinstall the script every hour or so. The script is to reinstall a database for a CMS i have designed that I allow people to use on my website but I dont want the thing being exploited and people just adding any old crap to it, so a fresh install will take off all the rubbish and put back my good stuff.

Any help would be great

thanks
barry

Ps i have been using a php script that i wrote to do much the same thing on a seperate website but i have to put the sql directly into the php script which I dont realy want to do this time as the sql is pretty huge and i think putting it directly into the php script wont work correctly.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 30th, 2009, 5:07 am

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Joined: Feb 10, 2004
  • Posts: 13455
  • Loc: Florida
  • Status: Offline

Post January 30th, 2009, 6:55 am

Are you able to setup cron tabs on the machine hosting the MySQL server ?

If so you might be able to bypass PHP all together and setup a cron job to login to MySQL and load the query from a file.
Code: [ Select ]
mysql -uusername -ppassword < "/path/to/query.sql"
Strong with this one, the sudo is.
  • barry
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jan 28, 2005
  • Posts: 115
  • Loc: scotland
  • Status: Offline

Post January 30th, 2009, 8:45 am

joebert wrote:
Are you able to setup cron tabs on the machine hosting the MySQL server ?

If so you might be able to bypass PHP all together and setup a cron job to login to MySQL and load the query from a file.
Code: [ Select ]
mysql -uusername -ppassword < "/path/to/query.sql"



thanks for the post mate

i found a php script to do it and setup a cron to run it hourly

thanks for the tip though ;)

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 244 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.