Monit和mysql,但不能在my.cnf中使用skip-networking

我试图找出解决办法。 基本上,我希望服务器以外的任何人能够尝试连接到我们的数据库。 因此,我已经添加到my.conf中:

skip-networking 

这是我skip-networking没有启用时得到的:

 tcp6 0 0 :::3306 :::* LISTEN 6957/mysqld unix 2 [ ACC ] STREAM LISTENING 3911682 6957/mysqld /var/run/mysqld/mysqld.sock 

但是当我添加它时,它将带走3306端口上的“聆听”:

 sudo netstat -lnp | grep mysql unix 2 [ ACC ] STREAM LISTENING 3909565 7356/mysqld /var/run/mysqld/mysqld.sock 

我的monit脚本非常简单:

  check process mysqld with pidfile /var/run/mysqld/mysqld.pid group database group mysql start program = "/etc/init.d/mysql start" stop program = "/etc/init.d/mysql stop" if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 3 times within 4 cycles then restart if failed unixsocket /var/run/mysqld/mysqld.sock protocol mysql for 3 times within 4 cycles then restart if 5 restarts with 5 cycles then timeout depend mysql_bin depend mysql_rc check file mysql_bin with path /usr/sbin/mysqld group mysql include /etc/monit/templates/rootbin check file mysql_rc with path /etc/init.d/mysql group mysql include /etc/monit/templates/rootbin 

有什么build议么? 我只想保持skip-networking ,但如果要停止Monit的工作,我们可能没有select(除非有解决办法)

更新:如果我删除以下行,build议:

 if failed host localhost port 3306 protocol mysql with timeout 15 seconds for 3 times within 4 cycles then restart 

然后当我重新启动Monit,我得到这个错误:

 [UTC Oct 9 13:00:45] error : 'mysqld' process is not running [UTC Oct 9 13:00:45] info : 'mysqld' trying to restart [UTC Oct 9 13:00:45] info : 'mysqld' start: /etc/init.d/mysql [UTC Oct 9 13:01:15] error : 'mysqld' failed to start (exit status 127) -- /etc/init.d/mysql: Cannot execute --sync_binlog=0 

更新2:好吧,所以不是我想到的解决scheme – 但它有同样的效果。 我所做的是将端口3306closures到127.0.0.1 以外的任何地方,这意味着它将只允许来自服务器的传入stream量,而不是外部。 然后,我从my.cnf中删除了skip-networking部分,因为我现在不想closuresnetworking

谢谢

安迪

你可以绑定到127.0.0.1,但是请记住,接口只能访问mysql。