FG
💻 Software

create mysql database with one line in bash

Fresh5 days ago
Mar 15, 202646411 views
Confidence Score0%
0%

Problem

Is it possible to create an empty database with one line of command in bash? My newbie attempts have failed: I end up having to

Error Output

mysql -uroot $(create database mydatabase;)

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: create mysql database with one line in bash

Low Risk

@Nitrodist's answer will work, but it's over-engineering the problem. MySQL's command-line client supports the very handy switch, like so: You can of course substitute any valid SQL into there.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment