简体   繁体   English

如何更改mysql服务的路径

[英]How to change the path of mysql services

After installation of MySQL 5.1.73, I've added the path variable to安装 MySQL 5.1.73 后,我已将路径变量添加到

C:\Program Files\MySQL\MySQL Server 5.1\bin

And I tried in the command line:我在命令行中尝试过:

"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --install

It shows:表明:

The service already exists!
The current server installed: "c:\Program Files\MySQL\mysqld" --defaults-file=my.ini MySQL

But as you can see the path I set is "C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\mysqld" but not "c:\\Program Files\\MySQL\\mysqld" So no doubt when I type:但是正如你所看到的,我设置的路径是“C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin\\mysqld”而不是“c:\\Program Files\\MySQL\\mysqld”所以当我输入时毫无疑问:

net start mysql

I get:我得到:

System error 2 has occurred.

The system cannot find the file specified.

How to change the strange wrong directory?如何更改奇怪的错误目录? I've never set this wrong directory before.我以前从未设置过这个错误的目录。 My platform is Windows 7 Enterprise我的平台是 Windows 7 Enterprise

Open registry editör (regedit.exe) then find mysql service (HKLM --> SYSTEM --> CurrentControlSet --> Services --> MySQL) and correct the ImagePath setting.打开注册表编辑器 (regedit.exe) 然后找到 mysql 服务(HKLM --> SYSTEM --> CurrentControlSet --> Services --> MySQL)并更正 ImagePath 设置。

Updating the path to MySQL in regedit in Windows 10 {Computer\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\MySQL}在 Windows 10 {Computer\\HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\MySQL} 中的 regedit 中更新 MySQL 的路径

Alternatively you can search for c:\\Program Files\\MySQL\\mysqld in registry and change to C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin或者,您可以在注册表中搜索c:\\Program Files\\MySQL\\mysqld并更改为C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin

Then run in cmd (admin mode)然后在cmd下运行(管理员模式)

  1. cd C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin cd C:\\Program Files\\MySQL\\MySQL Server 5.1\\bin
  2. mysqld.exe --initialize mysqld.exe --初始化
  3. open services and start mysql service OR run: net start mysql打开服务并启动 mysql 服务或运行:net start mysql

This error may happen as you install Window recently and didn't to any updates of something.当您最近安装 Window 并且没有对某些内容进行任何更新时,可能会发生此错误。 What I took is as follows我采取的是如下

  1. Run "regedit.exe" from start button.从开始按钮运行“regedit.exe”。
  2. From within "Registry Editor" Edit --> Find (Ctrl + F)从“注册表编辑器”中编辑 --> 查找 (Ctrl + F)
  3. Use "mysql" as the "search key"使用“mysql”作为“搜索键”
  4. Now, you would find the following window现在,您会发现以下窗口

在此处输入图片说明

  1. Right click [ImagePath] icon and choose "Modify".右键单击 [ImagePath] 图标并选择“修改”。
  2. Enter your 'mysqld.exe' full pathname there as shown in the above image.如上图所示,在那里输入您的“mysqld.exe”完整路径名。

After I did above procedure, no "System error 2" occurred when I execute following command.执行上述步骤后,执行以下命令时未出现“系统错误 2”。

DOS> net start mysql DOS> 网络启动mysql

Good luck.祝你好运。

Is this question more appropriate for SuperUser or DBA site?这个问题更适合超级用户还是 DBA 站点?

--install try to run mysql as Windows service. --install 尝试将 mysql 作为 Windows 服务运行。 If you only supply --install, it will use the default service name which is MySQL.如果您只提供 --install,它将使用默认的服务名称,即 MySQL。 The error message indicates there is already a Windows service called MySQL so you can't install another service with the same name.该错误消息表明已经有一个名为 MySQL 的 Windows 服务,因此您无法安装另一个同名的服务。

You can first remove the existing service:(Admin command line)您可以先删除现有服务:(管理员命令行)

sc delete MySQL

Then run your install command.然后运行你的安装命令。 But before that you have to be sure MySQL service is really deleted, since the service only will be removed after the process ends.但在此之前,您必须确保 MySQL 服务真的被删除了,因为该服务只有在该过程结束后才会被删除。 If not, then you can kill that mysql process in Task Manager.如果没有,那么您可以在任务管理器中终止该 mysql 进程。

The seconde way is leave the existing MySQL service there and create another one:第二种方法是将现有的 MySQL 服务留在那里并创建另一个:

"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld" --install MySQL_Instance2 --defaults-file="path-to-my.ini"

But you have to be sure the new my.ini use differenct settings than your existing myslq instance's my.ini like port number, or the new service won't start successfully.但是您必须确保新的 my.ini 使用与现有 myslq 实例的 my.ini 不同的设置,如端口号,否则新服务将无法成功启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM