Start MySQL with dynamic IP address in Ubuntu

 put these code in /etc/init.d/mysql

  1. #pick up the new IP address 
  2. IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'` 
  3.  
  4. # replacement in my.cnf 
  5.  OLD=`cat /etc/mysql/my.cnf  | grep 'bind-address'| awk '{ print $3}'` 
  6.    
  7.  sed -i "s/$OLD/$IP/g" /etc/mysql/my.cnf  

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章