Assistance with MySQL my.cnf file preventing mysql from starting

I recently upgraded to Ubuntu 20.04 and mysql8. I have a my.cnf file located in /etc/mysql/. which, upon first installation of the mysql 8 ignores that file (because it’s listed as world writeable) and runs msyql fine. However, I need to do things like load data from files stored on the server and need to configure things like sql_mode to respect these scenarios. When I attempt to restrict access to the my.cnf file by doing the following:

chown mysql:mysql /etc/mysql/my.cnf
chmod 600 /etc/mysql/my.cnf

mysql won’t run and I end up removing and reinstalling mysql 8 all over again. Weirdly, the file always seems to revert back to full rights for everyone (777). I’m not sure why that’s occurring.

The full contents of the my.cnf file information is posted below:

# This file has been automatically moved from your previous
# /etc/mysql/my.cnf, with just this comment added at the top, to maintain MySQL
# operation using your previously customised configuration.

# To switch to the new packaging configuration for automated management of

# /etc/mysql/my.cnf across multiple variants:
# 1. Move your customisations from this file to /etc/mysql/conf.d/ and
#    to /etc/mysql/<variant>.conf.d/ as appropriate.
# 2. Run "update-alternatives --remove my.cnf /etc/mysql/my.cnf.migrated"
# 3. Remove the file /etc/mysql/my.cnf.migrated

# The MySQL database server configuration file.
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
# For explanations see

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
port		= 3306
socket		= 

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
socket		= 
nice		= 0

# * Basic Settings
user		= mysql
pid-file	= /var/run/mysqld/
socket		= /var/run/mysqld/mysqld.sock
port		= 3306
basedir		= /usr
datadir		= /var/lib/mysql
tmpdir		= /tmp
lc-messages-dir	= /usr/share/mysql

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address		=
# * Fine Tuning
# Obsolete key_buffer option renamed to key_buffer_size by maintainer script
key_buffer_size		= 16M
max_allowed_packet	= 16M
thread_stack		= 258K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
# Obsolete myisam-recover option renamed to myisam_recover_options by maintainer script
myisam_recover_options	= BACKUP
max_connections         = 50
#table_cache            = 64
#thread_concurrency     = 10
# * Query Cache Configuration
query_cache_limit = 2M

#default setting for query_cache_size was 16M
query_cache_size        = 15M
# * Logging and Replication
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
# Error log - should be very few entries.
log_error = /var/log/mysql/error.log
# Here you can see queries with especially long duration
#log_slow_queries	= /var/log/mysql/mysql-slow.log
#long_query_time = 2
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id		= 1
#log_bin			= /var/log/mysql/mysql-bin.log
expire_logs_days	= 10
max_binlog_size         = 100M
#binlog_do_db		= include_database_name
#binlog_ignore_db	= include_database_name
# * InnoDB
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# * Security Features
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem

max_allowed_packet	= 16M

#no-auto-rehash	# faster start of mysql but no tab completition

# Obsolete key_buffer option renamed to key_buffer_size by maintainer script
# changed from 16 to 8M -djb
key_buffer_size		= 8M

# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
!includedir /etc/mysql/conf.d/

I’m wondering if there’s a way to get a clean my.cnf file to start over again and also wondering why the file permissions seemed to be weird on this.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hi there @davidboudia,

Note that the /etc/mysql/my.cnf file is not really a file but a symlink.

It basally is a ‘short cut’ to the /etc/alternatives/my.cnf file which on the other hand is a short cut to the /etc/mysql/mysql.cnf file.

/etc/mysql/my.cnf -> /etc/alternatives/my.cnf
/etc/alternatives/my.cnf -> /etc/mysql/mysql.cnf

Changing the permissions to the symlink will not work.

What is the exact error that you get? And also what is the exact change that you are trying to make?

If you want to make some changes to your MySQL variables for example, you need to make the change in the /etc/mysql/mysql.conf.d/mysqld.cnf file.

Hope that this helps! Regards, Bobby

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.