如何从shell命令创建mysql数据库? [英] How to create mysql database from shell command?

查看:289
本文介绍了如何从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.

这篇关于如何从shell命令创建mysql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆