Skip to main content

Replace SQL db with another every hour

Comments

3 comments

  • cPRex Jurassic Moderator
    Hey there! I believe this should be doable as long as the user has shell access enabled. This would let the user have access to mysql on the command line, allowing them to import the database from a cron. I tested this on my end by doing the following: -placed the original database.sql in the /home/username directory -ensured the cPanel user has shell access After that, I created the database and ensured there was a user that could access it. I was then able to run this command from a Bash script to update the database: mysql -u username_testuser -p PASSWORD-GOES-HERE username_testdb < original_db.sql
    That Bash script would then just get called hourly by the cron job. I would expect that to work just as well on your end, but let me know if you run into issues.
    0
  • milo695
    Hey there! I believe this should be doable as long as the user has shell access enabled. This would let the user have access to mysql on the command line, allowing them to import the database from a cron. I tested this on my end by doing the following: -placed the original database.sql in the /home/username directory -ensured the cPanel user has shell access After that, I created the database and ensured there was a user that could access it. I was then able to run this command from a Bash script to update the database: mysql -u username_testuser -p PASSWORD-GOES-HERE username_testdb < original_db.sql
    That Bash script would then just get called hourly by the cron job. I would expect that to work just as well on your end, but let me know if you run into issues.

    Thank you for this, but I only have Reseller account without the Shell access in this scenario, is there a way to pull this off somehow or should I contact Hosting company to implement this for me?
    0
  • cPRex Jurassic Moderator
    These commands would actually be run as the cPanel user on the account, so your reseller status wouldn't matter.
    0

Please sign in to leave a comment.