MySQLCheck command not optimize tables?

Discussion in 'Site & Server Administration' started by postcd, Feb 19, 2015.

  1. #1
    Hello,

    on the server i ran:
    mysqlcheck -u root -pmypassword --all-databases --check --auto-repair -F -C
    it all looked OK, but i seen that data i deleted from mysql myisam table was still there awaiting optimization (i mean disk space was not freed and was visible as table overhead

    So i want to ask how to adjust command so it really optimise myisam tabla i mentioned?

    i tried to add optimize tag:
    mysqlcheck -u root -pmypassword --all-databases --check --auto-repair -F -C --optimize

    but it says "Error: mysqlcheck doesn't support multiple contradicting commands."

    so i need to do second run of mysqlcheck with different parameters? I would like to avoid that as i have very high number of dbs,tables and data. Im runnign that on cronjob. Thank you
     
    postcd, Feb 19, 2015 IP
  2. OlgaSeCom

    OlgaSeCom Active Member

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #2
    Hello,
    Try to run this on your server: for i in `mysql -pmypassword -e "show databases;"`; do mysqlcheck -u root -pmypassword --check --auto-repair --optimize $i; done
    Then please reboot mysql.
     
    OlgaSeCom, Feb 27, 2015 IP
  3. postcd

    postcd Well-Known Member

    Messages:
    1,043
    Likes Received:
    9
    Best Answers:
    1
    Trophy Points:
    190
    #3
    OlgaSeCom: Thx, are You sure it will optimize only tables with overhead and not all tables?
     
    postcd, Feb 27, 2015 IP
  4. OlgaSeCom

    OlgaSeCom Active Member

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    56
    #4
    It will optimize all tables and all it`s database except InnoDB
     
    OlgaSeCom, Feb 27, 2015 IP