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

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

MySQL version

 mysql Ver 14.14 Distrib 5.5.14, for Win64 (x86) 

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

+4
source share
2 answers

Change your single quotes to double quotes:

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

I am running mysql Ver 14.14. Distributing 5.5.16 for Win32 (x86)

+11
source

You can also repeat your sql statement in mysql, for example:

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

Source: https://habr.com/ru/post/1384017/


All Articles