简体   繁体   中英

In MySQL, how to run sql in the command line?

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.

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)

你也可以将你的sql语句回显到mysql中,例如:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM