[英]Running MySql script from Cmd.exe in MS Windows 7
I am trying to run a MySQL script from the cmd.exe command line in windows 7. 我正在尝试从Windows 7中的cmd.exe命令行运行MySQL脚本。
I have tried referencing MySQL by its physical path, then by enclosing its physical path in quotes, and then by creating a MYSQL_HOME
variable, placing MYSQL_HOME
in the windows PATH variable, and calling MySQL from the command line. 我尝试通过其物理路径引用MySQL,然后将其物理路径括在引号中,然后创建一个
MYSQL_HOME
变量,将MYSQL_HOME
放在Windows PATH变量中,然后从命令行调用MySQL。 But all of these approaches are giving errors. 但是所有这些方法都给错误。 How can I get the simple
--init-file=...
command to run from cmd.exe? 如何获得从cmd.exe运行的简单
--init-file=...
命令?
Here is a print screen of the failed commands that I have tried: 这是我尝试过的失败命令的打印屏幕:
Here are the names and values of the windows environmental variables that I set: 以下是我设置的Windows环境变量的名称和值:
variable name variable value
MYSQL_HOME C:\Program Files\MySQL\MySQL Server 5.0\bin
PATH ...;%MYSQL_HOME%;...
Here is the printscreen resulting from following Rahul's advice: 这是遵循Rahul的建议得到的打印屏幕:
First of all you should quote your path using "
instead of '
like 首先,你应该使用引用您的路径
"
,而不是'
像
cd "C:\Program Files\MySQL\MySQL Server 5.0\bin"
once cd
to the folder, run command dir
and see if mysql.exe
is present or not (for verification) cd
到该文件夹后,运行dir
命令并查看mysql.exe
是否存在(用于验证)
Again, if you have just added below environment variable, it will not take effect on the current command window. 同样,如果您刚刚添加了以下环境变量,则该变量在当前命令窗口中不会生效。 Exit and re-open the command window for it to take effect.
退出并重新打开命令窗口,以使其生效。
MYSQL_HOME C:\Program Files\MySQL\MySQL Server 5.0\bin
EDIT: 编辑:
Are you sure --init-file
option is present (or) a valid option to use. 您确定
--init-file
选项存在(或)要使用的有效选项。 If I am not wrong, then there is no --init-file
option present. 如果我没看错,则不存在
--init-file
选项。
Try mysql --help
or mysql -?
尝试
mysql --help
或mysql -?
and see if that option really exists or not. 并查看该选项是否确实存在。
EDIT1: EDIT1:
you are doing it wrongly. 您做错了。 In this case, you should be using
mysqld.exe
instead like 在这种情况下,您应该使用
mysqld.exe
代替
mysqld --init-file=C:\\mysql-init.txt
See this Mysql documents which clearly mentioned how to reset root password 请参阅此Mysql文档,其中明确提到了如何重置root密码
Resetting the Root Password: Windows Systems 重置根密码:Windows系统
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.