I want to optimize my database and decided to start by running mysqltuner, but it showed me so many errors that I don’t know what to undertake, I couldn’t advise what configuration I should specify based on my server settings

  • My tarif on Linode is:

       4    GB RAM
       2    CPU Cores
       80   GB SSD Storage
       4    TB Transfer
       40   Gbps Network In
       4000 Mbps Network Out

I start my mysql tuner:

[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.6.43-log
[OK] Operating on 64-bit architecture

-------- Log file Recommendations ------------------------------------------------------------------
[--] Log file: /var/log/mysql/mysqld.log(0B)
[OK] Log file /var/log/mysql/mysqld.log exists
[OK] Log file /var/log/mysql/mysqld.log is readable.
[!!] Log file /var/log/mysql/mysqld.log is empty
[OK] Log file /var/log/mysql/mysqld.log is smaller than 32 Mb
[OK] /var/log/mysql/mysqld.log doesn't contain any warning.
[OK] /var/log/mysql/mysqld.log doesn't contain any error.
[--] 0 start(s) detected in /var/log/mysql/mysqld.log
[--] 0 shutdown(s) detected in /var/log/mysql/mysqld.log

-------- Storage Engine Statistics -----------------------------------------------------------------
[--] Data in InnoDB tables: 766.8M (Tables: 110)
[OK] Total fragmented tables: 0

-------- Analysis Performance Metrics --------------------------------------------------------------
[--] innodb_stats_on_metadata: OFF
[OK] No stat updates during querying INFORMATION_SCHEMA.

-------- Security Recommendations ------------------------------------------------------------------
[OK] There are no anonymous accounts for any database users
[OK] All database users have passwords assigned
[!!] There is no basic password file list!

-------- CVE Security Recommendations --------------------------------------------------------------
[--] Skipped due to --cvefile option undefined

-------- Performance Metrics -----------------------------------------------------------------------
[--] Up for: 34d 20h 2m 32s (117M q [38.983 qps], 1M conn, TX: 1265G, RX: 20G)
[--] Reads / Writes: 99% / 1%
[--] Binary logging is disabled
[--] Physical Memory     : 3.9G
[--] Max MySQL memory    : 4.1G
[--] Other process memory: 150.6M
[--] Total buffers: 3.5G global + 1.1M per thread (151 max threads)
[--] P_S Max memory usage: 403M
[--] Galera GCache Max memory usage: 0B
[!!] Maximum reached memory usage: 4.0G (104.78% of installed RAM)
[!!] Maximum possible memory usage: 4.1G (106.26% of installed RAM)
[!!] Overall possible memory usage with other process exceeded memory
[OK] Slow queries: 0% (8K/117M)
[OK] Highest usage of available connections: 65% (99/151)
[OK] Aborted connections: 0.04%  (465/1327070)
[!!] name resolution is active : a reverse name resolution is made for each new connection and can reduce performance
[!!] Query cache may be disabled by default due to mutex contention.
[OK] Query cache efficiency: 49.1% (54M cached / 110M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (9 temp sorts / 3M sorts)
[!!] Joins performed without indexes: 122027
[OK] Temporary tables created on disk: 16% (9M on disk / 57M total)
[OK] Thread cache hit rate: 99% (6K created / 1M connections)
[OK] Table cache hit rate: 73% (366 open / 499 opened)
[OK] Open file limit used: 0% (47/10K)
[OK] Table locks acquired immediately: 100% (23M immediate / 23M locks)

-------- Performance schema ------------------------------------------------------------------------
[--] Memory used by P_S: 403.9M
[--] Sys schema isn't installed.

-------- ThreadPool Metrics ------------------------------------------------------------------------
[--] ThreadPool stat is disabled.

-------- MyISAM Metrics ----------------------------------------------------------------------------
[!!] Key buffer used: 18.3% (1M used / 8M cache)
[OK] Key buffer size / total MyISAM indexes: 8.0M/101.0K
[OK] Read Key buffer hit rate: 100.0% (77M cached / 4 reads)
[!!] Write Key buffer hit rate: 0.0% (41M cached / 30 writes)

-------- InnoDB Metrics ----------------------------------------------------------------------------
[--] InnoDB is enabled.
[--] InnoDB Thread Concurrency: 0
[OK] InnoDB File per table is activated
[OK] InnoDB buffer pool / data size: 1.0G/766.8M
[!!] Ratio InnoDB log file size / InnoDB Buffer pool size (50 %): 256.0M * 2/1.0G should be equal 25%
[!!] InnoDB buffer pool <= 1G and Innodb_buffer_pool_instances(!=1).
[--] InnoDB Buffer Pool Chunk Size not used or defined in your version
[OK] InnoDB Read buffer efficiency: 100.00% (27261013604 hits/ 27261058993 total)
[!!] InnoDB Write Log efficiency: 81.25% (48468 hits/ 59653 total)
[OK] InnoDB log waits: 0.00% (0 waits / 108121 writes)

-------- Replication Metrics -----------------------------------------------------------------------
[--] Galera Synchronous replication: NO
[--] No replication slave(s) for this server.
[--] Binlog format: STATEMENT
[--] XA support enabled: ON
[--] Semi synchronous replication Master: Not Activated
[--] Semi synchronous replication Slave: Not Activated
[--] This is a standalone server

-------- Recommendations ---------------------------------------------------------------------------
General recommendations:
    Reduce your overall MySQL memory footprint for system stability
    Dedicate this server to your database for highest performance.
    Configure your accounts with ip or subnets only, then update your configuration with skip-name-resolve=1
    Adjust your join queries to always utilize indexes
    Consider installing Sys schema from https://github.com/mysql/mysql-sys
    Before changing innodb_log_file_size and/or innodb_log_files_in_group read this: 
Variables to adjust:
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***
    query_cache_size (=0)
    query_cache_type (=0)
    join_buffer_size (> 256.0K, or always use indexes with JOINs)
    innodb_log_file_size should be (=128M) if possible, so InnoDB total log files size equals to 25% of buffer pool size.
    innodb_buffer_pool_instances (=1)

And my.cnf

    bind-address =
    ignore-db-dir = lost+found
    explicit_defaults_for_timestamp = 1
    # Disabling symbolic-links is recommended to prevent assorted security risks

    # Recommended in standard MySQL setup

    query_cache_limit       = 1048576
    query_cache_size        = 2684354560
    query_cache_type        = 1

    innodb_flush_method     = O_DIRECT
    innodb_file_per_table   = 1
    innodb_buffer_pool_size = 1024M
    innodb_log_file_size = 256M
    innodb_flush_log_at_trx_commit = 2

    slow_query_log_file= /var/log/mysql/log-slow-queries.log

    # Set unicode by default
    character-set-server  = utf8mb4
    collation-server      = utf8mb4_general_ci


How can I optimize my file based on this information?

Why do I ask because all tables have indexes, but requests are processed very slowly which affects the visits and usability of the site

  • 1
    Query optimisation is much more advanced then only running mysqltuner ("once"). Query optimisation is like art. It requires you to run EXPLAIN query and how to read the EXPLAIN output and deep knowledge how MySQL uses indexes for differenct types of queries .. Sometime query rewrites are also needed to gain more performance May 5 '19 at 20:22
  • If your site is slow, then first you need to identify what is the bottle neck. You must not jump to trying to optimise mysql db settings. Not to mention the fact that optimising mysql db settings is a dba task, not a sw developer one.
    – Shadow
    May 5 '19 at 20:31
  • But I see when I go to the pages for the first time the site loads for a long time, when I enter the second time the caching works and the site loads quickly. Accordingly, I concluded that I have a problem in the database
    – Logan
    May 5 '19 at 20:34
  • I think every programmer should understand this, isn't it? This programming is in any way. I think this is the correct section for my question.
    – Logan
    May 5 '19 at 21:02
  • Nope, this has got nothing to do with programming, this is a completely different beast.
    – Shadow
    May 5 '19 at 21:25

The tool almost always recommends OPTIMIZE TABLE. Don't bother. It is almost always more trouble than benefit.

There is no reliable formula for maximum memory. So ignore those [!!].

Joins performed without indexes: 122027 may or may not be an issue. Is your system running slower than you would like? If so, what are your 'slow' queries?

Key buffer used: 18.3% (1M used / 8M cache) and Write Key buffer hit rate -- bogus. You are not using MyISAM; this is a trivial amount being wasted.

For deeper analysis, follow the instructions here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy