如何从shell命令创建mysql数据库?
问题描述:
我正在寻找类似createdb在psql或任何其他解决方案,将允许我在shell命令的帮助下创建数据库。任何提示?
I'm looking for something like createdb in psql or any other solution that would allow me to create databse with a help of a shell command. Any hints?
答
cat filename.sql | mysql -u username -p # type mysql password when asked for it
其中filename.sql包含所有sql来创建你的数据库。 or ...
Where filename.sql holds all the sql to create your database. Or...
echo "create database databasename" | mysql -u username -p
如果你真的只想创建一个数据库。
If you really only want to create a database.