用批处理启动MySQL命令行工具_MySQL
Jun 01, 2016 pm 01:47 PMbitsCN.com
最近在看MySQL,安装好之后,每次在开始菜单去启动MySQL命令行工具的时候,都是直接用root用户连接我本地的数据库
输入密码开始工作,但是要连接服务器上的MySQL的话,就要去CMD下运行 : MySQL --h172.18.1.22 -uroot -p123456
每次的输入自然让人厌烦,批处理出马解决这个问题,先上代码:
---------------
@echo off
set /p var="链接本地MySQL请按1,链接172.18.1.22服务器请按2,退出请按0: "
if %VAR%==1 GOTO Local
if %VAR%==2 GOTO Server22
if %VAR%==0 GOTO End
:Local
start "Local" "D:ProgramMySQLinMySQL.exe" -uroot -p123456
Goto End
:Server22
start "Server23" "D:ProgramMySQLinMySQL.exe" -h172.18.1.22 -uroot -p123456
Goto End
:End
-----------------------
这段批处理中,先用到等待键盘输入来控制,本例中输入1,2,0来控制流程,没有对其他情况做处理
输入1之后按回车,代码会根据你的输入去start exe文件,本例中是带有参数的
出现这个控制台,这里说明一下,这个控制台是新打开的,之前那个已经关闭了,因为对我已经没有用了,如果你还要用,在end 标签下做控制即可。
虽然现在MySQL的GUI工具又多又强大,不过有些时候还是想进控制台看看,因为之前写批处理调exe文件传参数的地方不熟,试了好几种形式才发现最简单的就是正确的……所有把代码贡献出来给那些和我一样的新丁了。
bitsCN.com

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of the issuance price and issuance time of LOOM coins

Ouyi official website registration portal 2025

The latest registration portal for Ouyi official website 2025

The latest ranking list of 2025 crypto digital currency trading app software

Top 10 Global Security and Easy-to-use Virtual Currency Exchange Rankings 2025

Ranking of safe and reliable digital currency exchange apps in 2025

Ouyi Exchange app domestic download tutorial

Top 10 safe and reliable digital currency trading platforms in 2025
