6
mysql -uroot -proot -e 'create database mydb;'

MySQL version is

mysql  Ver 14.14 Distrib 5.5.14, for Win64 (x86)

When I run the command, it just shows the help information. Please help.

3
  • 2
    it works for me, show the whole console output might be helpful. Commented Dec 1, 2011 at 1:00
  • can you please try double quotes in Linux machine ? Commented Dec 1, 2011 at 1:09
  • double quotes works in linux. Commented Dec 1, 2011 at 1:12

2 Answers 2

12

Change your single quotes to double quotes:

mysql -uroot -proot -e "create database mydb;"

I'm running mysql Ver 14.14 Distrib 5.5.16, for Win32 (x86)

Sign up to request clarification or add additional context in comments.

4 Comments

Not for me, but double quotes does. If I use single quotes I only get the help for the command.
my version is: Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1
@James.Xu: I think Krister Andersson may well be right. Obviously in Bash, single-quotes would work fine; but the OP's MySQL version is ... for Win64 (x86), so it's quite plausible that the OP is using the Windows command prompt, which will treat 'create database mydb;' as three arguments, just like "'create" database "mydb;'".
Yes, I am using Windows 7. it has to use double quotes.
0

You also can echo your sql statement into mysql, e.g.:

echo "select sum(table_rows) from information_schema.tables" | mysql -uUSR -pPASSWD

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.