"Go" MySQL specifies the path to start

Source: Internet
Author: User

/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


Here's what to go:
Http://chengxuyuan.naxieshir.com/fenlei/2/p/152.html

The vast majority of MySQL in the boot time to load a configuration file, I believe most of the development have encountered similar problems, the machine starts when the MySQL default will be started, the default use of MySQL command can be connected to the server, but where the data is stored, the parameters are set how many, etc. This needs to know which configuration file MySQL uses, then MySQL boot is in what order to load the configuration file?

Different versions of the machine load the same order, the following example is the case of 5.1.10.

Common configuration file paths under Linux machines

file name function
/etc/my.cnf Global Options
/etc/mysql/my.cnf Global options (as of MySQL 5.1.15)
SYSCONFDIR/my.cnf Global Options
$MYSQL_HOME/my.cnf Server-specific Options
defaults-extra-file The file specified with--defaults-extra-file=path  
~/my.cnf User-specific Options

When no startup commands are added, MySQL checks the configuration file for existence by default, from top to bottom, using the first discovered file as the startup file.

Therefore, when starting the mysqld, make sure to determine whether the above path has a corresponding configuration file, to avoid loading the wrong file, causing some strange problems.

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

View the current mysqld startup load file

You can usually find the answer 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

More advanced, depending on the file information of the process to view

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

Using Mysqld's--verbose function

Server ~ #/usr/sbin/mysqld--help--verbose--skip-networking--pid-file=$ (tempfile) 2>/dev/null | GREP-A1 ' default options is read ' default options is read from the following files in the given order:/etc/my.cnf/etc/m YSQL/MY.CNF ~/.my.cnf

"Go" MySQL specifies the path to start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.