Skip to content
Advertisement

Need a script File to clear Cache Tables in a Drupal Database

I need to take a dump of MySQL Database, i usaully do these manual steps do Perform dumping.

    login to phpmyadmin
    select database
    select sql tab
    paste these lines

        TRUNCATE watchdog;
        TRUNCATE cache; and
        TRUNCATE cache_admin_menu;

And click on OK to clean the cache.

I need to carryout the same activity via sime automated way, so that i can run in Cron job    

Advertisement

Answer

[root@localhost home]# mysql -u root -ppasswd < /root/Downloads/testscript.sql

 

I had create one file with name testscript.sql

text in the file as follows

/*
 * My First MySQL Script – testscript.sql.
 * You need to run this script with an authorized user.
 */
USE dbname;                     — Set system database ‘dbname’ as the current database
TRUNCATE `cache`;
TRUNCATE `cache_admin_menu`;
TRUNCATE `cache_block`;
TRUNCATE `cache_bootstrap`;
TRUNCATE `cache_field`;
TRUNCATE `cache_filter`;
TRUNCATE `cache_form`;
TRUNCATE `cache_image`;
TRUNCATE `cache_libraries`;
TRUNCATE `cache_menu`;
TRUNCATE `cache_page`;
TRUNCATE `cache_path`;
TRUNCATE `cache_rules`;
TRUNCATE `cache_token`;
TRUNCATE `cache_update`;
TRUNCATE `cache_views`;
TRUNCATE `watchdog`;

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement