DB Maintenance

    版本為 22:20, 3 Oct 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    Tablespace Shrink

    資料表刪除大量的歷史資料列後,所屬的 Tablespace 檔案大小不會自動變小,必須執行維護指令

    mysql> OPTIMIZE table foo;
    

    一次優化所有的資料表

    reference to undefined name 'syntax' Exception of type 'MindTouch.Deki.Script.Runtime.DekiScriptUndefinedNameException' was thrown. (click for details)

    mysql.log 管理維護

    手動清除

    $> mysqladmin -uroot -p flush-logs
    

    使用 logrotate 服務自動管理
    1. 新增 /etc/logrotate.d/mysqld:

    /var/log/mysql/*.log {
       create 644 mysql mysql
       notifempty
       daily
       rotate 5
       missingok
       nocompress
       sharedscripts
       postrotate
       # run if mysqld is running
       if test -n "`ps acx|grep mysqld`"; then
         /usr/bin/mysqladmin flush-logs
       fi
    endscript
    }
    

    2. 新增 mysql 管理帳號密碼檔

    $> vi ~/.my.cnf
    
    [mysqladmin]
    user            = root
    password        = YourPass
    
    $> chmod 0600 ~/.my.cnf 
    
    Powered by MindTouch Core