Reputation: 610
I am following this tutorial to setup a MySQL server on my Digital Ocean droplet, but using Ubuntu 16.04.
When i set 'bind-address' as localhost or the public server's ip I can restart the server, but when I try to use private ip I get the an error.
$ sudo service mysql restart
Throws:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Mon 2017-07-03 23:23:36 UTC; 10s ago
Process: 16717 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 16709 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 16717 (code=exited, status=1/FAILURE); : 16718 (mysql-systemd-s)
Tasks: 2
Memory: 332.0K
CPU: 338ms
CGroup: /system.slice/mysql.service
└─control
├─16718 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─16768 sleep 1
Jul 03 23:23:36 inradar-db-production systemd[1]: Starting MySQL Community Server...
Jul 03 23:23:38 inradar-db-production systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
journalctl -xe (last lines)
Jul 03 23:24:37 inradar-db-production audit[16926]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/16926/status" pid=169
Jul 03 23:24:37 inradar-db-production audit[16926]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/"
Jul 03 23:24:37 inradar-db-production kernel: audit: type=1400 audit(1499124277.901:460): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld"
Jul 03 23:24:37 inradar-db-production kernel: audit: type=1400 audit(1499124277.901:461): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld"
Jul 03 23:24:37 inradar-db-production audit[16926]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/16926/status" pid=169
Jul 03 23:24:37 inradar-db-production kernel: audit: type=1400 audit(1499124277.905:462): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld"
Jul 03 23:24:39 inradar-db-production systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
lines 2193-2214/2214 (END)
What's the problem?
Upvotes: 2
Views: 4515
Reputation: 342
I had this problem too. What exactly did you add to your my.cnf file?
On install, my my.cnf file was completely empty. When I added just the bind-address line I got the same error as you.
However when I add [mysqld] above it, it works... so try adding this:
[mysqld]
bind-address = 0.0.0.0
A bit of additional info: When I checked my journal I could see these error logs which seem to suggest that mysql is looking for something extra in the my.conf file:
Aug 03 13:22:03 ubuntu mysql-systemd-start[19667]: my_print_defaults: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23!
Aug 03 13:22:03 ubuntu mysql-systemd-start[19667]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
I can now connect to my db remotely.
Hope this helps!
Upvotes: 2
Reputation: 461
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
https://www.cyberciti.biz/faq/ubuntu-linux-howto-disable-apparmor-commands/
Upvotes: -1