设置bind-address时MySQL服务器重启错误

时间:2017-07-03 22:07:25

标签: mysql ubuntu-16.04 digital-ocean

我正在按照本教程在我的Digital Ocean Droplet上设置MySQL服务器,但使用的是Ubuntu 16.04。

https://www.digitalocean.com/community/tutorials/how-to-migrate-a-mysql-database-to-a-new-server-on-ubuntu-14-04

当我设置' bind-address'作为localhost或公共服务器的ip我可以重新启动服务器,但是当我尝试使用私有ip时,我得到了一个错误。

$ sudo service mysql restart

抛出:

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(最后一行)

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)

问题是什么?

2 个答案:

答案 0 :(得分:2)

我也有这个问题。您刚刚在my.cnf文件中添加了什么内容?

安装时,我的my.cnf文件完全为空。当我只添加绑定地址行时,我得到了与你相同的错误。

然而,当我在它上面添加[mysqld]时,它可以工作......所以尝试添加这个:

[mysqld]
bind-address = 0.0.0.0

一些额外的信息:当我检查我的日志时,我可以看到这些错误日志,这似乎表明mysql正在my.conf文件中寻找额外的东西:

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!

我现在可以远程连接到我的数据库。

希望这有帮助!

答案 1 :(得分:-1)

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/