Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Description of mysql pid parameters in my.cnf configuration file

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The mysql pid parameter in the my.cnf configuration file states that when the MySQL instance starts, its own process ID is written to a file-- that is, the pid file. The file can be controlled by the parameter pid_file. It is located in the database directory by default, and the file name is hostname. pid:

Mysql > show variables like 'pid_file'\ G

* * 1. Row *

Variable_name: pid_file

Value: / usr/local/mysql/data/xen-server.pid

1 row in set (0.00 sec)

The following is the understanding:

Most mysql have to load a configuration file when starting. I believe most developers have encountered similar problems. Mysql starts by default when the machine starts, and the server can be connected by default using mysql commands, but where the data is stored, how many parameters are set, and so on. You need to know which configuration file is used by mysql, so in what order does mysql start to load the configuration files?

Different versions of the machine are loaded in different order, and the following column takes 5.1.10 as an example.

The configuration file path file name function commonly used on Linux machines / etc/my.cnfGlobal options/etc/mysql/my.cnfGlobal options (as of MySQL 5.1.15) SYSCONFDIR/my.cnfGlobal options$MYSQL_HOME/my.cnfServer-specific optionsdefaults-extra-fileThe file specified with--defaults-extra-file=path~/my.cnfUser-specific options

When no startup command is added, mysql will by default check the existence of the configuration file from top to bottom, using the first found file as the startup file.

Therefore, when starting mysqld, be sure to determine whether there is a corresponding configuration file under the above path to avoid loading the wrong file and causing some strange problems.

Of course, if you don't want to use the configuration file in the default load order, you can add-- defaults-file='path/to/my.cnf' to the startup command to specify the configuration file to use.

View the load file for the current mysqld startup

The answer can usually be found with the following command

Server ~ # ps ax | grep'[m] ysqld'10801? Ssl 0:27 / usr/sbin/mysqld-defaults-file=/etc/mysql/my.cnf-basedir=/usr-datadir=/var/lib/mysql-pid-file=/var/run/mysqld/mysqld.pid-socket=/var/run/mysqld/mysqld.sock

At a more advanced level, look at the file information of the process

123server ~ # cat / proc/$ (pidof mysqld) / cmdline | tr'\ 0'\ n'/usr/sbin/mysqld--defaults-file=/etc/mysql/my.cnf

Use the verbose function that comes with mysqld

123server ~ # / usr/sbin/mysqld-- help-- verbose-- skip-networking-- pid-file=$ (tempfile) 2 > / dev/null | grep-A1 'Default options are read'Default options are read from the following files in the given order:/etc/my.cnf / etc/mysql/my.cnf ~. My.cnf

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report