适用于 Windows 的 MySQL 命令行客户端

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3246482/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:33:12  来源:igfitidea点击:

MySQL command line client for Windows

mysqlwindows

提问by PawelRoman

Is there any nice command line MySQL client for windows? I mean a single exe that allows connecting and running a sample query. I've googled and only could find big graphical environments like toad or mysql workbench. I need only a simple command line tool, where can I download sth like this?

有没有很好的 Windows 命令行 MySQL 客户端?我的意思是允许连接和运行示例查询的单个 exe。我用谷歌搜索,只能找到像蟾蜍或 mysql 工作台这样的大型图形环境。我只需要一个简单的命令行工具,我在哪里可以下载这样的东西?

EDIT: I don't want to install the whole MySQL package on my PC. I know it's inside the mysql package but how do I download only this cmd line client. Because i don't need anything else.

编辑:我不想在我的 PC 上安装整个 MySQL 包。我知道它在 mysql 包内,但我如何只下载这个 cmd 行客户端。因为我不需要别的了。

采纳答案by Sylvain

When you go to the MySQL download page, choose the platform "Microsoft Windows". Then download the "Windows (x86, xx-bit), ZIP Archive" (be sure to select the one with size over 140M.

当您转到 MySQL下载页面时,选择平台“Microsoft Windows”。然后下载“Windows (x86, xx-bit), ZIP Archive”(一定要选择大小超过140M的那个。

The binaries will be in the "bin" folder.

二进制文件将位于“bin”文件夹中。

I understand that this is not just the client binaries, but at least you don't have to install and setup the entire server.

我知道这不仅仅是客户端二进制文件,但至少您不必安装和设置整个服务器。

回答by Buhake Sindi

mysql.exe can do just that....

mysql.exe 可以做到这一点....

To connect,

连接,

mysql -u root -p(press enter)

mysql -u root -p(按回车)

It should prompt you to enter root password (u = username, p = password)

它应该提示您输入 root 密码(u = 用户名,p = 密码)

Then you can use SQL database commands to do pretty much anything....

然后你可以使用 SQL 数据库命令做几乎任何事情......

回答by spicecat

You can choose only install the client during server install. The website only offers to let you download the full installer (grab whatever version you want from http://www.mysql.com/downloads/mysql/).

您可以选择在服务器安装期间只安装客户端。该网站只提供让您下载完整安装程序(从http://www.mysql.com/downloads/mysql/获取您想要的任何版本)。

In the install wizard, when prompted for installation type (typical, minimal, custom), choose 'Custom'. On the next screen, select to NOT install the server, and proceed with the rest of the install as normal.

在安装向导中,当提示安装类型(典型、最小、自定义)时,选择“自定义”。在下一个屏幕上,选择不安装服务器,然后照常进行其余的安装。

When you're done, you should see just the relevant client programs (mysql, mysqldump, etc) in C:\Program Files\MySQL..\bin

完成后,您应该只在 C:\Program Files\MySQL..\bin 中看到相关的客户端程序(mysql、mysqldump 等)

回答by dams50

You can also download MySql workbench(31Mo) which includes mysql.exeand mysqldump.exe.

您还可以下载MySql 工作台(31Mo),其中包括mysql.exemysqldump.exe.

I successfully tested this when i had to run Perl scripts using DBD:MySqlmodule to run SQL statements against a distant MySql db.

当我不得不使用DBD:MySql模块运行 Perl 脚本来针对远程 MySql 数据库运行 SQL 语句时,我成功地测试了这一点。

回答by basavaraj_S

Its pretty simple. I saved the mysql community server in my D:\drive. Hence this is how i did it.

它很简单。我在我的D:\驱动器中保存了 mysql 社区服务器。因此,我就是这样做的。

Goto D:\mysql-5.7.18-winx64\binand in the address bar type cmd and press enter, so command prompt will open. Now if you're using it for the first time type as mysql -u root -ppress enter. Then it will ask for password, again press enter. Thats it you are connected to the mysql server.

转到D:\mysql-5.7.18-winx64\bin并在地址栏中键入 cmd 并按 Enter,因此将打开命令提示符。现在,如果您是第一次使用它,请mysql -u root -p按回车键输入。然后它会要求输入密码,再次按回车键。就是这样,您已连接到 mysql 服务器。

Before this make sure wamp or xampp any of the local server is runningbecause i couldn't able to connect to mysql wihthout xampp running. enter image description here

Before this make sure wamp or xampp any of the local server is running因为我无法在 xampp 运行的情况下连接到 mysql。 在此处输入图片说明

enter image description here

在此处输入图片说明

Happy Coding.

快乐编码。

回答by basavaraj_S

You can access mySQL in command line just by typing:

您只需键入以下内容即可在命令行中访问 mySQL:

C:\www\mysql\bin> mysql -u root -p

After which you can type sql commands normally such as:

之后,您可以正常键入 sql 命令,例如:

mysql> SHOW DATABASES;

Here, I am assuming you mySQL installation directory is C:\www\mysql.

在这里,我假设您的 mySQL 安装目录是C:\www\mysql.

回答by SnapShot

If you are looking for tools like the the mysql and mysqldump command line client for Windows for versions around mysql Ver 14.14 Distrib 5.6.13, for Win32 (x86)it seems to be in HOMEDRIVE:\Program Files (x86)\MySQL\MySQL Workbench version

如果您正在为mysql Ver 14.14 Distrib 5.6.13左右的版本寻找用于 Windows 的 mysql 和 mysqldump 命令行客户端等工具,对于 Win32 (x86),它似乎位于HOMEDRIVE:\Program Files (x86)\MySQL\MySQL工作台版本

This directory is also not placed in the path by default so you will need to add it to your PATH environment variable before you can easily run it from the command prompt.

默认情况下,此目录也不放置在路径中,因此您需要将其添加到 PATH 环境变量中,然后才能从命令提示符轻松运行它。

Also, there is a mysql utilities console but it does not work for my needs. Below is a list of the capabilities on the mysql utilities console in case it works for you:

此外,还有一个 mysql 实用程序控制台,但它不能满足我的需要。以下是 mysql 实用程序控制台上的功能列表,以防它对您有用:

Utility           Description
----------------  ---------------------------------------------------------
mysqlauditadmin   audit log maintenance utility
mysqlauditgrep    audit log search utility
mysqldbcompare    compare databases for consistency
mysqldbcopy       copy databases from one server to another
mysqldbexport     export metadata and data from databases
mysqldbimport     import metadata and data from files
mysqldiff         compare object definitions among objects where the
                  difference is how db1.obj1 differs from db2.obj2
mysqldiskusage    show disk usage for databases
mysqlfailover     automatic replication health monitoring and failover
mysqlfrm          show CREATE TABLE from .frm files
mysqlindexcheck   check for duplicate or redundant indexes
mysqlmetagrep     search metadata
mysqlprocgrep     search process information
mysqlreplicate    establish replication with a master
mysqlrpladmin     administration utility for MySQL replication
mysqlrplcheck     check replication
mysqlrplshow      show slaves attached to a master
mysqlserverclone  start another instance of a running server
mysqlserverinfo   show server information
mysqluserclone    clone a MySQL user account to one or more new users

回答by Peter DeGregorio

I have similar requirement where I need a MySQL client but not server (running in a virtual machine and don't want any additional overhead) and for me the easiest thing was to install MySQL community server taking typical installation options but NOT configure the server, so it never starts, never runs. Added C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin to system path environment variable and I'm able to use the MySQL command line client mssql.exe and mysqladmin.exe programs.

我有类似的需求,我需要一个 MySQL 客户端而不是服务器(在虚拟机中运行,不需要任何额外的开销),对我来说,最简单的事情是安装 MySQL 社区服务器,采用典型的安装选项,但不配置服务器,所以它永远不会启动,永远不会运行。将 C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin 添加到系统路径环境变量中,我可以使用 MySQL 命令行客户端 mssql.exe 和 mysqladmin.exe 程序。

回答by Naktibalda

mysql.exe is included in mysql package. You don't have to install anything additionally.

mysql.exe 包含在 mysql 包中。您无需另外安装任何东西。

回答by Shanmuga

download the mysql-5.0.23-win32.zip (this is the smallest possible one) from archived versions in mysql.com website

从 mysql.com 网站的存档版本下载 mysql-5.0.23-win32.zip(这是最小的一个)

cut and paste the installation in c drive as mysql folder

将安装在c盘中剪切并粘贴为mysql文件夹

then install then follow instructions as per this page: https://cyleft.wordpress.com/2008/07/20/fixing-mysql-service-could-not-start-1067-errors/

然后安装,然后按照此页面的说明进行操作:https: //cyleft.wordpress.com/2008/07/20/fixing-mysql-service-could-not-start-1067-errors/