Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 583
user595234 Avatar asked Dec 01 '11 00:12

user595234


People also ask

How query MySQL database command line?

To access a specific database, type the following command at the mysql> prompt, replacing dbname with the name of the database that you want to access: Copy use dbname; Make sure you do not forget the semicolon at the end of the statement. After you access a database, you can run SQL queries, list tables, and so on.


1 Answers

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)

like image 165
Cyclonecode Avatar answered Oct 13 '22 01:10

Cyclonecode