啟動mysql配置檔案的啟動方式

2021-07-30 11:05:02 字數 3003 閱讀 1559

mysql 配置檔案載入位置與順序: 

1./usr/local/mysql/bin/mysqld –verbose –help >help.txt 2>&1 

(/usr/local/mysql/bin/mysqld –verbose –help 這個命令生成所有mysqld選項和可配置變數的列表 然後重定向到help.txt,標準錯誤也重定向到這個檔案中) 

2.檢視這個檔案:vi help.txt 

3.搜尋my.cnf:

from

the following files in

thegiven order:

(預設選項在給定的順序從下列檔案中讀取:)

/etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf

the following groups are read: mysqld server mysqld-5.7

the following options may be given

asthe

first argument:

--print-defaults print the program argument list and exit.

--defaults-file=# only read default options from the given file #.(載入指定的不載入其他)

--defaults-extra-file=# read this file after the global files are read.

(載入預設的之後在載入指定的)

so:my.cnf是按照這個順序讀取的,如果有那個配置不一樣但是有多個my.cnf是按照最後乙個配置為準的

1、mysqld 

啟動mysql伺服器:./mysqld –defaults-file=/etc/my.cnf –user=root 

客戶端連線: 

mysql –defaults-file=/etc/my.cnf 

or mysql -s /tmp/mysql.sock

2、mysqld_safe 

啟動mysql伺服器:./mysqld_safe –defaults-file=/etc/my.cnf –user=root & 

客戶端連線: 

mysql –defaults-file=/etc/my.cnf 

or mysql -s /tm/mysql.sock

3、mysql.server 

cp -v /usr/local/mysql/support-files/mysql.server /etc/init.d/ 

chkconfig –add mysql.server 

啟動mysql伺服器:service mysql.server  

客戶端連線:同1、2

4、mysqld_multi 

mkdir $mysql_base/data2 

cat <<-eof>> /etc/my.cnf 

[mysqld_multi] 

mysqld = /usr/local/mysql/bin/mysqld_safe 

mysqladmin = /user/local/mysql/bin/mysqladmin 

user = mysqladmin 

password = mysqladmin

[mysqld3306] 

port = 3306 

socket = /tmp/mysql3306.sock 

pid-file = /tmp/mysql3306.pid 

skip-external-locking 

key_buffer_size = 16m 

max_allowed_packet = 1m 

table_open_cache = 64 

sort_buffer_size = 512k 

net_buffer_length = 8k 

read_buffer_size = 256k 

read_rnd_buffer_size = 512k 

myisam_sort_buffer_size = 8m 

basedir = /usr/local/mysql 

datadir = /usr/local/mysql/data

[mysqld3307] 

port = 3307 

socket = /tmp/mysql3307.sock 

pid-file = /tmp/mysql3307.pid 

skip-external-locking 

key_buffer_size = 16m 

max_allowed_packet = 1m 

table_open_cache = 64 

sort_buffer_size = 512k 

net_buffer_length = 8k 

read_buffer_size = 256k 

read_rnd_buffer_size = 512k 

myisam_sort_buffer_size = 8m 

basedir = /usr/local/mysql 

datadir = /usr/local/mysql/data2 

eofmysql>grant shutdown on . to 『mysqladmin』@』localhost』 identified by 『mysqladmin』 with grant option;

mysql>grant shutdown on . to 『mysqladmin』@』localhost』 identified by 『mysqladmin』 with grant option;

啟動mysql伺服器:./mysqld_multi –defaults-file=/etc/my.cnf start 3306-3307 

關閉mysql伺服器:mysqladmin shutdown

MySQL讀取配置檔案的順序 啟動方式 啟動原理

一 mysql讀取配置檔案的順序 讀取順序 etc my.cnf etc mysql my.cnf usr etc my.cnf my.cnf 命令驗證 root mysql mysql verbose help grep my.cnf order of preference,my.cnf,mysq...

MySQL讀取配置檔案的順序 啟動方式 啟動原理

一 mysql讀取配置檔案的順序 讀取順序 etc my.cnf etc mysql my.cnf usr etc my.cnf my.cnf 命令驗證 root mysql mysql verbose help grep my.cnf order of preference,my.cnf,mysq...

mysql修改配置檔案後的啟動錯誤

修改完mysql配置檔案後,重新啟動報錯 starting mysql.error the server quit without updating pid file usr local mysql var izbp1b0a77gz.pid 連線mysql的時候報錯 error 2002 hy000...