Skip to content

Linux: Mysql

Warren G Brown edited this page Sep 8, 2022 · 1 revision

MySQL

Show status information

mysql -e 'show global status;'

MySQL Table Sizes

mysql;
SELECT IFNULL(B.engine,'Total') "Storage Engine", CONCAT(LPAD(REPLACE(FORMAT(B.DSize/POWER(1024,pw),3),',',''),17,' '),' ',SUBSTR(' KMGTP',pw+1,1),'B') "Data Size", CONCAT(LPAD(REPLACE(FORMAT(B.ISize/POWER(1024,pw),3),',',''),17,' '),' ',SUBSTR(' KMGTP',pw+1,1),'B') "Index Size", CONCAT(LPAD(REPLACE(FORMAT(B.TSize/POWER(1024,pw),3),',',''),17,' '),' ',SUBSTR(' KMGTP',pw+1,1),'B') "Table Size" FROM (SELECT engine,SUM(data_length) DSize,SUM(index_length) ISize,SUM(data_length+index_length) TSize FROM information_schema.tables WHERE table_schema NOT IN ('mysql','information_schema','performance_schema') AND engine IS NOT NULL GROUP BY engine WITH ROLLUP) B,(SELECT 3 pw) A ORDER BY TSize;
quit;

Wordpress MySQL Database dump

run from same location as wp-config.php

mkdir .mysqldump/; stat wp-config.php -c "%U"|xargs sh -c 'chown ${1}. .mysqldump' "${0}"; (cat wp-config.php  | grep DB_NAME | awk -F"'" '{print$4}'; stat wp-config.php -c "%U"; ) | xargs sh -c  'mysqldump ${1} > .mysqldump/${1}.sql;chown ${2}. .mysqldump/${1}.sql;' "${0}"; echo "The databases are found in $(pwd)/"; find .mysqldump/ -name *.sql;

MySQL Update information

MySQL 5.1 Version Changes

    table_cache - > table_open_cache'
    log_slow_queries -> slow_query_log 

MySQL 5.5 Version Changes

    safe_show_database -> REMOVED
    skip_locking -> REMOVED
    skip_symlink -> REMOVED
    master-*' -> "REMOVED - now must be set within the server, cannot be set via my.cnf
        Actually just the options:
            master-host
            master-password
            master-port
            master-user 

MySQL 5.6 Version Changes

    log-slow-queries -> REMOVED (it's always on if the log file is set)
    performance_schema=0 is recommended, unless performance_schema is required.
    MySQL's old password hashing format
        It's not actually removed, but it is very broken by this point.