echo "Creating new MySQL database..."
mysql -uroot -p${rootpasswd} -e "CREATE DATABASE ${dbname} /*\!40100 DEFAULT CHARACTER SET ${charset} */;"
注意使用-e参数
完整脚本如下:
相关地址:https://stackoverflow.com/questions/33470753/create-mysql-database-and-user-in-bash-script
MySql创建数据库指定字符集
mysql>create database if not exists test03 default character set = 'utf8';
Query OK, 1 row affected (0.00 sec)
https://www.cnblogs.com/chuanzhang053/p/9121506.html
Google关键字:shell script create database mysql
利用shell脚本批量创建数据库以及数据表
https://blog.csdn.net/jiaqingShareing/article/details/82148481