MySQL mysql.conf configuration example for Ubuntu 20.04 LTS (Focal Fossa)

Get the default configuration file mysql.conf for MySQL, optimized for Ubuntu 20.04 LTS (Focal Fossa). This example configuration ensures optimal compatibility and performance for MySQL, making it easy to set up and adjust to meet your needs.

Find and download the configuration file here: /etc/init/mysql.conf.

For more configurations and setup guides, visit our related files section to further customize your system.

    description     "MySQL 5.7 Server"
author          "Mario Limonciello <superm1@ubuntu.com>"

start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]

respawn
respawn limit 2 5

env HOME=/etc/mysql
umask 007

# The default of 5 seconds is too low for mysql which needs to flush buffers
kill timeout 300

pre-start script
    ## Fetch a particular option from mysql's invocation.
    # Usage: void mysqld_get_param option
    mysqld_get_param() {
      /usr/sbin/mysqld --print-defaults \
        | tr " " "\n" \
        | grep -- "--$1" \
        | tail -n 1 \
        | cut -d= -f2
    }

    # priority can be overriden and "-s" adds output to stderr
    ERR_LOGGER="logger -p daemon.err -t /etc/init/mysql.conf -i"

    #Sanity checks
    [ -r $HOME/my.cnf ]
    [ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld
    /lib/init/apparmor-profile-load usr.sbin.mysqld

    # check for diskspace shortage
    datadir=`mysqld_get_param datadir`
    BLOCKSIZE=`LC_ALL=C df --portability $datadir/. | tail -n 1 | awk '{print $4}'`
    if [ $BLOCKSIZE -le 4096 ] ; then
      echo "$0: ERROR: The partition with $datadir is too full!" >&2
      echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
      exit 1
    fi
end script

exec /usr/sbin/mysqld

post-start script
   for i in `seq 1 30` ; do
        /usr/bin/mysqladmin --defaults-file="${HOME}"/debian.cnf ping && {
            exec "${HOME}"/debian-start
            # should not reach this line
            exit 2
        }
        statusnow=`status`
        if echo $statusnow | grep -q 'stop/' ; then
            exit 0
        elif echo $statusnow | grep -q 'respawn/' ; then
            exit 1
        fi
        sleep 1
    done
    exit 1
end script

    
  

Config Details

Location
/etc/init/mysql.conf
Operating system
Ubuntu 20.04 LTS (Focal Fossa)
Length
63 lines
MD5 checksum
5b097f4a577d63c60a8f6ca01b12bc47

Usage

Download the raw file with wget or curl

Wget

wget -O mysql.conf.example https://exampleconfig.com/static/raw/mysql/ubuntu20.04/etc/init/mysql.conf

cURL

curl https://exampleconfig.com/static/raw/mysql/ubuntu20.04/etc/init/mysql.conf > mysql.conf.example