本地计算机上的 MySQL 服务启动然后停止

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35670755/
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 21:37:33  来源:igfitidea点击:

the MySQL service on local computer started and then stopped

mysqlservicewindow

提问by Kem Bardly

the MySQL service on local computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.

本地计算机上的 MySQL 服务启动然后停止。如果其他服务或程序未使用某些服务,则它们会自动停止。

Can anyone resolve this issue? Thanks.

任何人都可以解决这个问题吗?谢谢。

回答by Dorine Mae

After installing it by mysqld --install. Try this mysqld --initialize. We got the same problem but it's now working.

安装后通过mysqld --install. 试试这个mysqld --initialize。我们遇到了同样的问题,但现在可以正常工作了。

回答by jhersey29

If using version 8 and you edit the my.ini I found that Notepad is putting 3 hex characters at the beginning of the my.ini file. EF BB BF. Deleting the 3 characters from the beginning of the file in a hex editor fixes the problem.

如果使用版本 8 并且您编辑 my.ini,我发现记事本在 my.ini 文件的开头放置了 3 个十六进制字符。EF BB BF。在十六进制编辑器中删除文件开头的 3 个字符可解决此问题。

In version 8 they are accidentally putting Unicode characters in the ini file. This is causing Notepad to save the file with Byte order mark characters.

在版本 8 中,他们不小心将 Unicode 字符放入 ini 文件中。这导致记事本使用字节顺序标记字符保存文件。

The following line in the file is the culprit "The line # range from 1 to 2^32 ? 1. “Unique” means that each ID must be different." has 3 Unicode characters. This is causing notepad to append the byte order mark to the text file.

文件中的以下行是罪魁祸首“第 # 行范围从 1 到 2^32 ? 1。“唯一”意味着每个 ID 必须不同。有 3 个 Unicode 字符。这导致记事本将字节顺序标记附加到文本文件。

回答by Warwick

Also remember to give NETWORK SERVICE permission to the folder:

还要记住为文件夹授予 NETWORK SERVICE 权限:

  1. Right-click Datafolder
  2. Select Properties
  3. Select Securitytab
  4. Click Advanced
  5. Click Change Permissions...
  6. Click Add...
  7. Type NETWORK SERVICE
  8. Click Check Names
  9. Click OK
  10. Select Full Control
  11. Click OK– four times
  12. Start MySQL service
  1. 右键单击Data文件夹
  2. 选择 Properties
  3. 选择Security标签
  4. 点击 Advanced
  5. 点击 Change Permissions...
  6. 点击 Add...
  7. 类型 NETWORK SERVICE
  8. 点击 Check Names
  9. 点击 OK
  10. 选择 Full Control
  11. 点击OK——四次
  12. 启动 MySQL 服务

回答by Han Xiong

In my case, I tried to open a DOS prompt and go to the MySQL bin\directory and issue the below command:

就我而言,我尝试打开 DOS 提示符并转到 MySQLbin\目录并发出以下命令:

mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server 5.0\my.ini" --standalone --console

And it shows me I was missing the "C:\Program Files\MySQL\MySQL Server 5.0\Uploads"folder; I built one and problem solved.

它告诉我我丢失了"C:\Program Files\MySQL\MySQL Server 5.0\Uploads"文件夹;我建了一个,问题解决了。

回答by Maninderpal Singh

  1. Open Service
  2. Right click on MYSQL service
  3. select Log on
  4. check local system account
  5. start service
  1. 开放服务
  2. 右键单击MYSQL服务
  3. 选择登录
  4. 检查本地系统帐户
  5. 启动服务

回答by vulp

This may be because of changing lower_case_table_namesafter a server has been already initialized.

这可能是因为lower_case_table_names在服务器已经初始化之后发生了变化。

From the docs:

从文档:

lower_case_table_names can only be configured when initializing the server. Changing the lower_case_table_names setting after the server is initialized is prohibited.

lower_case_table_names 只能在初始化服务器时配置。禁止在服务器初始化后更改lower_case_table_names 设置。

The solution to this problem is to set lower_case_table_namesparameter at server installation as described in the following answer:

此问题的解决方案是lower_case_table_names在服务器安装时设置参数,如以下答案中所述:

Can't set lower_case_table_names in MySQL 8.x on Windows 10

无法在 Windows 10 上的 MySQL 8.x 中设置 lower_case_table_names

回答by tom anderson

Using Community 8.0.17, upgraded from 8.0.16

使用社区 8.0.17,从 8.0.16 升级

There may be a more secure way of doing this, but since I'm just running a dev box:

可能有一种更安全的方法可以做到这一点,但由于我只是在运行一个开发框:

  1. navigate to the \data folder
  2. make SURE the \data folder is EMPTY. If files exist the --initialize option will fail
  3. give SYSTEM Full Control permissions on the \data folder
  4. go back to your command prompt
  5. run mysqld --initialize
  1. 导航到 \data 文件夹
  2. 确保 \data 文件夹是空的。如果文件存在 --initialize 选项将失败
  3. 授予 SYSTEM 对 \data 文件夹的完全控制权限
  4. 回到你的命令提示符
  5. 运行 mysqld --initialize

you should see all of the required data file structures in the data folder now. If they are not created, the mysqld process has contention or improper security to write into the folder correctly.

您现在应该会在数据文件夹中看到所有必需的数据文件结构。如果未创建它们,则 mysqld 进程存在争用或不正确的安全性无法正确写入文件夹。

Now start your named service in whatever fashion you want (SC/NET/service.msc, etc)

现在以您想要的任何方式启动您的命名服务(SC/NET/service.msc 等)

Assuming all of the files were created properly by --initialize the service will start.

假设所有文件都通过 --initialize 正确创建,服务将启动。

回答by Germa Vinsmoke

Nothing was working for me but then I checked here. I ran that command qc sc mysql57and copied the value of BINARY_PATH_NAMEfrom it. After that I checked thisand changed the value of lower_case_table_namesfrom 0 to 2 in my.inifile. Then in the command prompt, I ran this command - << BINARY_PATH_NAME >> --install-manual. After that, I started the MySQL57 service and it worked.

没有什么对我有用,但后来我检查了这里。我运行该命令qc sc mysql57并从中复制了 的值BINARY_PATH_NAME。之后我检查了这个并将文件中的值lower_case_table_names从0更改为2 my.ini。然后在命令提示符下,我运行了这个命令 - << BINARY_PATH_NAME >> --install-manual。之后,我启动了 MySQL57 服务并且它工作了。

回答by PhuVu94

Follow the below instruction as below to save your day:

请按照以下说明节省您的一天:

If you modify my.ini not correct, you will find the trouble "the MySQL service on local computer started and then stopped". So you need to check your my.ini in "C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" again to make sure there is no strange command. If you don't know and want to restore to original, you can search on web with key word "my.ini configuration", download the latest and copy it to "C:\ProgramData\MySQL\MySQL Server 8.0\my.ini"

如果你修改my.ini不正确,你会发现“本地计算机上的MySQL服务启动然后停止”的问题。所以你需要再次检查“C:\ProgramData\MySQL\MySQL Server 8.0\my.ini”中的my.ini,确保没有奇怪的命令。如果不知道想恢复原样,可以在网上搜索关键词“my.ini配置”,下载最新的复制到“C:\ProgramData\MySQL\MySQL Server 8.0\my.ini ”

For whom delete the SQL service on Window or Linux, You can follow these step below:

对于在Window或Linux上删除SQL服务的人,您可以按照以下步骤操作:

(Window)

(窗户)

Delete Current Service

删除当前服务

You need to stop MySQL80/MySQLXX in Service before carry out the action below Open commandLine of Window and run as administrator

你需要在服务中停止MySQL80/MySQLXX,然后才能执行下面的操作打开Window的命令行并以管理员身份运行

sc delete mysql80<= If you use mysql80, it will delete MySQL80 in Service

sc delete mysql80<= 如果使用mysql80,会删除Service中的MySQL80

sc delete mysql<= If you use "mysql --initliaze", it will delete MySQL in Service

sc delete mysql<= 如果使用“mysql --initliaze”,则会删除Service中的MySQL

The command mysqld --initializejust create MySQL in Service of Window or Linux

命令mysqld --initialize只是在 Window 或 Linux 的服务中创建 MySQL

So when you check it Path Executable, it misses my.ini so you can't use you MySQL Server although MySQL Service is working

因此,当您检查 Path Executable 时,它​​会丢失 my.ini,因此您无法使用 MySQL 服务器,尽管 MySQL 服务正在运行

For MySQL80

对于 MySQL80

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --install MySQL80 --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini"

"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --install MySQL80 --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini"

For MySQLXX

对于 MySQL XX

"C:\Program Files\MySQL\MySQL Server X.X\bin\mysqld.exe" --install MySQLXX --defaults-file="C:\ProgramData\MySQL\MySQL Server X.X\my.ini"

"C:\Program Files\MySQL\MySQL Server XX\bin\mysqld.exe" --install MySQLXX --defaults-file="C:\ProgramData\MySQL\MySQL Server XX\my.ini"

=> It will create MySQLXX Service working with my.ini

=> 它将使用 my.ini 创建 MySQLXX 服务

Then MySQL works normally and you won't need to install your MySQL again.

然后 MySQL 正常工作,您将不需要再次安装 MySQL。

I don't use Linux or Mac so I can't instruct - But you can find the answer above for reference

我不使用 Linux 或 Mac,所以我无法指导 - 但你可以在上面找到答案以供参考

回答by Alex Khimich

This error happened in my case when secure-file-priv was pointing to unexistent folder, make sure it exists and readable.

在我的情况下,当 secure-file-priv 指向不存在的文件夹时发生此错误,请确保它存在且可读。

The line of code example in my.ini: secure-file-priv="D:/MySQL/uploads"

my.ini 中的代码行示例: secure-file-priv="D:/MySQL/uploads"