How to create a database from shell command?

前端 未结 8 1962
难免孤独
难免孤独 2021-01-29 17:24

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?

8条回答
  •  梦谈多话
    2021-01-29 18:03

    cat filename.sql | mysql -u username -p # type mysql password when asked for it
    

    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.

提交回复
热议问题