Can we run MySQL query from windows command prompt? If so, how can we do that and process the query result through command prompt?
我们可以从Windows命令提示符运行MySQL查询吗?如果是这样,我们如何做到这一点并通过命令提示符处理查询结果?
5 个解决方案
#1
12
Try to use mysql — the MySQL command-line tool with '--execute=statement' or '-e statement' option.
尝试使用mysql - 带有'--execute = statement'或'-e statement'选项的MySQL命令行工具。
#2
4
You can install the MySQL client for windows and then use that for sending commands to a server.
您可以为Windows安装MySQL客户端,然后使用它来向服务器发送命令。
http://dev.mysql.com/doc/refman/5.0/en/mysql.html
You can use the following type of format for commands
您可以使用以下类型的命令格式
mysql db_name < script.sql > output.tab
mysql db_name
or
shell> mysql --user=user_name --password=your_password db_name
shell> mysql --user = user_name --password = your_password db_name
Then type an SQL statement, end it with “;”, \g, or \G and press Enter.
然后键入一个SQL语句,以“;”,\ g或\ G结束它,然后按Enter键。
#3
2
practical example of @devarts recommendation enter your user & password & Database
@devarts推荐的实际例子输入您的用户和密码和数据库
mysql -uUSER -pPASSWORD -e 'SHOW DATABASES;' -- list databases
mysql -uUSER -pPASSWORD MyDATABASE -e 'SHOW TABLES;' -- list tables in MyDATABASE
#4
1
Yes, We can access whole DB from command line.
1. Connect to DB (no space between -p and password)
mysql -h <host> -u <username> -p<password>
2. Now we can check how many db we have
show databases;
or many more commands and even we can execute quires through command line. For more command details http://g2pc1.bu.edu/~qzpeng/manual/MySQL%20Commands.htm
#5
0
Try this on Windows:
在Windows上试试这个:
- Open window console Run CMD
- type/copy: mysql -h hostname -u UserName -pPassWordTogether dbNAme -e"select * from table;" > D:/file.csv
- Easy and fast.
打开窗口控制台运行CMD
type / copy:mysql -h hostname -u UserName -pPassWordTogether dbNAme -e“select * from table;” > D:/file.csv
简单快捷。
Good Luck.
#1
12
Try to use mysql — the MySQL command-line tool with '--execute=statement' or '-e statement' option.
尝试使用mysql - 带有'--execute = statement'或'-e statement'选项的MySQL命令行工具。
#2
4
You can install the MySQL client for windows and then use that for sending commands to a server.
您可以为Windows安装MySQL客户端,然后使用它来向服务器发送命令。
http://dev.mysql.com/doc/refman/5.0/en/mysql.html
You can use the following type of format for commands
您可以使用以下类型的命令格式
mysql db_name < script.sql > output.tab
mysql db_name
or
shell> mysql --user=user_name --password=your_password db_name
shell> mysql --user = user_name --password = your_password db_name
Then type an SQL statement, end it with “;”, \g, or \G and press Enter.
然后键入一个SQL语句,以“;”,\ g或\ G结束它,然后按Enter键。
#3
2
practical example of @devarts recommendation enter your user & password & Database
@devarts推荐的实际例子输入您的用户和密码和数据库
mysql -uUSER -pPASSWORD -e 'SHOW DATABASES;' -- list databases
mysql -uUSER -pPASSWORD MyDATABASE -e 'SHOW TABLES;' -- list tables in MyDATABASE
#4
1
Yes, We can access whole DB from command line.
1. Connect to DB (no space between -p and password)
mysql -h <host> -u <username> -p<password>
2. Now we can check how many db we have
show databases;
or many more commands and even we can execute quires through command line. For more command details http://g2pc1.bu.edu/~qzpeng/manual/MySQL%20Commands.htm
#5
0
Try this on Windows:
在Windows上试试这个:
- Open window console Run CMD
- type/copy: mysql -h hostname -u UserName -pPassWordTogether dbNAme -e"select * from table;" > D:/file.csv
- Easy and fast.
打开窗口控制台运行CMD
type / copy:mysql -h hostname -u UserName -pPassWordTogether dbNAme -e“select * from table;” > D:/file.csv
简单快捷。
Good Luck.