Linux 如何在 MySQL 5.6 中更改 pid 文件的路径

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

How can i change the path of pid file in MySQL 5.6

mysqllinuxcentos

提问by user22

I have the MySQL 5.6 installed on CentOS6.4.

我在 CentOS6.4 上安装了 MySQL 5.6。

I read this

我读了这个

http://dev.mysql.com/doc/refman/5.6/en/server-default-changes.htmlhttp://dev.mysql.com/doc/refman/5.6/en/server-default-configuration-file.html

http://dev.mysql.com/doc/refman/5.6/en/server-default-changes.html http://dev.mysql.com/doc/refman/5.6/en/server-default-configuration-file .html

i have the my.cnfin /usr/my.cnffolder.

我有my.cnfin/usr/my.cnf文件夹。

Currently the pid file is being written in /tmpfolder because i got error few hours back

目前,pid 文件正在/tmp文件夹中写入,因为我在几个小时前遇到错误

now i have two questions

现在我有两个问题

  1. How to find where is MySQL writing the its data pid file
  2. How to chnage it
  1. 如何找到 MySQL 在哪里写入其数据 pid 文件
  2. 如何更改它

采纳答案by Flo Doe

To answer your questions:

回答您的问题:

1) To find out wehere mysql stores its pid file use the following:

1) 要找出 mysql 在哪里存储其 pid 文件,请使用以下命令:

mysql> show variables like '%pid%';
+---------------+-------------------------------+
| Variable_name | Value                         |
+---------------+-------------------------------+
| pid_file      | /var/lib/mysql/your-db.pid    |
+---------------+-------------------------------+

2) You can change this either by setting in in the my.cnf, here the option would look like the following pid-file=/var/lib/mysql/your-db.pid. Or you can change it by altering startup parameters and append --pid-file=/var/lib/mysql/your-db.pid. I would strongly suggest that you stick to the my.cnf option, the other solution would require some fiddling in your start-scripts.

2) 您可以通过在 my.cnf 中进行设置来更改此设置,这里的选项如下所示pid-file=/var/lib/mysql/your-db.pid。或者您可以通过更改启动参数和附加--pid-file=/var/lib/mysql/your-db.pid. 我强烈建议您坚持使用 my.cnf 选项,其他解决方案需要在您的启动脚本中进行一些调整。

3) You find the documentation here: http://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_pid-file

3)您可以在这里找到文档:http: //dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_pid-file

I just wanted to add that you can put the pid file wherever it suits you best, this means you don′t need to put it in your datadir or mysql-home. But a "clean" way to do so is under /var/run/under linux.

我只是想补充一点,你可以把 pid 文件放在最适合你的地方,这意味着你不需要把它放在你的 datadir 或 mysql-home 中。但是/var/run/在 linux下这样做是一种“干净”的方式。

回答by Aju

you can change the pid file in my.cnf it self. Mostly my.cnf will be available in /etc/my.cnf. you can edit the path of pid file. please find the below entry as an example...

您可以自行更改 my.cnf 中的 pid 文件。大多数 my.cnf 将在 /etc/my.cnf 中可用。您可以编辑pid文件的路径。请找到以下条目作为示例...

datadir = /var/lib/mysql pid-file=/var/lib/mysql/mysqld.pid

datadir = /var/lib/mysql pid-file=/var/lib/mysql/mysqld.pid