Hey Everyone, I really do apologise if this has already been asked. I am however a complete noob and cannot seem to solve this.
I am following this tutorial: https://www.digitalocean.com/community/tutorials/how-to-secure-mysql-and-mariadb-databases-in-a-linux-vps
I have got to the part that asks me to type in this command:
sudo nano /etc/mysql/my.cnf
Then it says: The first setting that we should check is the “bind-address” setting within the “[mysqld]” section. This setting should be set to your local loopback network device, which is “127.0.0.1”.
bind-address = 127.0.0.1
However, all I get is this ouput:
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/
Can someone tell me what I am supposed to do? I cannot seem to get past this stage to secure my mysql. There does not appear to be a [mysqld] section :/
Thank you
-WDG
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!
Sorry for the confusion. In some newer distributions the configuration is split into multiple files in order to make it easier to manage.
The setting you are looking for is most likely going to be in
/etc/mysql/mysql.conf.d/50-server.cnf
Those last two lines in the file you shared are telling the process to include all the configuration files on those two directories into my.cnf at runtime.
The tutorial you linked (How To Secure MySQL and MariaDB Databases in a Linux VPS), is a bit older older tutorial. However guides there are still relevant but there are changes in MySQL config structure for newer version.
For older versions (AFAIK prior to MySQL 5.7 and Ubuntu 16.04), all config things were in one file - /etc/mysql/my.cnf. That got changed, and now config are splitted in multiple files. The important part of /etc/mysql/my.cnf:
...
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
As you see it will look for .cnf files in following directories: /etc/mysql/conf.d/ and /etc/mysql/mysql.conf.d. When you list structure of them, you’ll see following:
total 8
-rw-r--r-- 1 root root 8 Jul 14 16:09 mysql.cnf
-rw-r--r-- 1 root root 55 Jul 14 16:09 mysqldump.cnf
total 8
-rw-r--r-- 1 root root 3028 Jul 14 16:09 mysqld.cnf
-rw-r--r-- 1 root root 21 Jul 11 2016 mysqld_safe_syslog.cnf
The file you need is /etc/mysql/mysql.conf.d/mysqld.cnf. Once you open it, in comment you’ll see:
#
# The MySQL database server configuration file.
#
And there will be [mysql] part with bind-address in it.
Once you change it, don’t forget to restart MySQL for changes to take effect:
- sudo systemctl restart mysql
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.