how to run a my sql script with php

  • barry
  • Graduate
  • Graduate
  • User avatar
  • Posts: 115
  • Loc: scotland

Post 3+ Months Ago

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.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

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"
  • barry
  • Graduate
  • Graduate
  • User avatar
  • Posts: 115
  • Loc: scotland

Post 3+ Months Ago

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 60 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.