I want to create a mysql database and then run some sql code from mysql.sql automating this using a shell script how would i do that, this is what i have now:
#!/bin/sh
echo Please enter hostname \(usually localhost\)
read hostname
echo Please enter your mySql Username:
read uName
echo Please enter your mySql password:
echo Desired database name:
read dbname
stty -echo
read password
stty echo
echo Running generatedb.sql...
mysql -u $uName -p $password
CREATE DATABASE $dbname;
can i just do mysql $dbname < mysql.sql after the create database line?
#!/bin/sh
echo Please enter hostname \(usually localhost\)
read hostname
echo Please enter your mySql Username:
read uName
echo Please enter your mySql password:
echo Desired database name:
read dbname
stty -echo
read password
stty echo
echo Running generatedb.sql...
mysql -u $uName -p $password
CREATE DATABASE $dbname;
can i just do mysql $dbname < mysql.sql after the create database line?
