if [ ! -f /var/log/databasesetup ]; then echo "CREATE USER 'codeeker' IDENTIFIED BY 'codeeker'" | mysql -uroot -proot echo "CREATE DATABASE mall" | mysql -uroot -proot echo "GRANT ALL ON mall.* TO 'codeeker'@'%'" | mysql -uroot -proot echo "flush privileges" | mysql -uroot -proot
touch /var/log/databasesetup #为了不重复执行创建用户的操作
if [ -f /vagrant/data/initial.sql ]; then mysql -uroot -proot codeeker < /vagrant/data/initial.sql fi fi
陷阱
错误一
报错误Lost connection to MySQL server at 'reading initial communication packet', system error: 0