Start MySQL with dynamic IP address in Ubuntu
put these code in/etc/init.d/mysql
- #pick up the new IP address
- IP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
-
- # replacement in my.cnf
- OLD=`cat /etc/mysql/my.cnf | grep 'bind-address'| awk '{ print $3}'`
-
- sed -i "s/$OLD/$IP/g" /etc/mysql/my.cnf