# Bash Script Stuck



## FlyingMadman (Feb 22, 2015)

I've written a script for automatic MySQL install and creating user but the code is stuck after `mysql -pcode`:


```
portsnap fetch extract
cd /usr/ports/databases/mysql55-client ; make install clean
cd /usr/ports/databases/mysql55-server ; make install clean
echo 'mysql_enable="YES"'>>/etc/rc.conf
/usr/local/etc/rc.d/mysql-server onestart
rehash
mysqladmin -uroot password "password"/usr/local/etc/rc.d/mysql-server onerestart
mysql -ppassword
GRANT ALL PRIVILEGES ON *.* TO 'mt2'@'localhost' IDENTIFIED BY 'mt2!@#' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
flush privileges;
quit
/usr/local/etc/rc.d/mysql-server onerestart
reboot
```


----------



## ANOKNUSA (Feb 22, 2015)

FlyingMadman said:


> code stuck after mysql -pcode



And where in your script would that be?


----------



## FlyingMadman (Feb 22, 2015)

`mysql -ppassword` part it is writing the password but not other codes


----------



## tobik@ (Feb 22, 2015)

Use a here-document to pipe those SQL queries to `mysql`.


----------

