如何从shell命令创建数据库? [英] How to create a database from shell command?
本文介绍了如何从shell命令创建数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找PostgreSQL中的createdb之类的东西,或任何其他允许我借助shell命令创建数据库的解决方案.有提示吗?
I'm looking for something like createdb in PostgreSQL or any other solution that would allow me to create database 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.或者...
Where filename.sql holds all the sql to create your database. Or...
echo "create database `database-name`" | mysql -u username -p
如果您真的只想创建一个数据库.
If you really only want to create a database.
这篇关于如何从shell命令创建数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文