16

I am trying to edit the my.cnf file to allow remote access and ultimately using software from my Windows Server to configure scheduled backup for MySQL Server.

I was following these instructions. However, the /etc/mysql/my.cnf file on my Ubuntu has only:

#
# 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
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * 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/
!includedir /etc/mysql/mysql.conf.d/

It doesn't contain any configuration that I can edit. Why is it like that?

  • All it means is that the file is just in default state, in original form since installation – Sergiy Kolodyazhnyy May 9 '19 at 1:45
29

Firstly, as A.B. rightly points out, the file is not empty. It has two rather important directives, namely

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

Those lines are saying that additional configuration files (.cnf in this case) can be found in the directories listed:

/etc/mysql/conf.d/
/etc/mysql/mysql.conf.d/

The latter of the two directories should contain mysqld.cnf. In other words, the appropriate configuration file should be:

/etc/mysql/mysql.conf.d/mysqld.cnf
  • 2
    somethings not right either way. when I edit the halfway-empty my.conf file and e.g. set wait_timeout = 600, the service mysql cannot be started anymore.. – phil294 Aug 4 '16 at 12:20
  • This is exact answer for the question. – Lasitha Benaragama Mar 14 '17 at 7:55
  • Wish I could find it 6 hours earlier! – neophyte Aug 3 '17 at 4:38
  • @Blauhirn Same here when I state a password here. Without it the service starts but apparently under [mysqld] not everything gets parsed right like wait_timout and password. – min hundje Jul 12 '19 at 11:28
5

The file isn't empty. It contains comments - the lines with a leading # - and import statements -the lines with a leading !. An import statement means other configurations will be used, too.

Editing a configuration file also means adding new configuration lines.

4

My file is the same. You need to add the correct group above the command you're trying to put in otherwise the service wont start.

To add bind-address you will need to add [mysqld] above it.

If you need to check what the groups are for the other commands, there's an example my.cnf file here.

If you want to enable remote connections from all interfaces (i.e 0.0.0.0), your file would look something like below, however be sure you set up your firewall correctly if you do.

#
# 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
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * 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/
!includedir /etc/mysql/mysql.conf.d/

[mysqld]    
bind-address = 0.0.0.0

Note the [mysqld] group.

3

In that case, that file is not the main where all the information about bind-adress, binlogs and etc include. But there is another file, where they include. Try this:

nano /etc/mysql/mysql.conf.d/mysqld.cnf

It helped me, and It should help you.

1

On Ubuntu 16.04 / MySQL 5.7 at least my.cnf is actually empty because it's a symlink to another file which symlinks back to mysql.cnf in /etc/mysql/mysql.conf.d mentioned in other answers. Make your changes here as mentioned above.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.