鐩綍
MySQL鏈嶅姟鍣紝鍗mysqld锛屾槸鍦MySQL瀹夎涓礋璐eぇ閮ㄥ垎宸ヤ綔鐨勪富绋嬪簭銆傛湇鍔″櫒闅忛檮浜嗗嚑涓浉鍏宠剼鏈紝褰撲綘瀹夎MySQL鏃跺畠浠彲浠ユ墽琛岃缃搷浣滐紝鎴栬呮槸甯姪浣犲惎鍔ㄥ拰鍋滄鏈嶅姟鍣ㄧ殑甯姪绋嬪簭銆
鏈妭鎻愪緵浜嗘湇鍔″櫒鍜岀浉鍏崇▼搴忕殑姒傝堪锛屼互鍙婃湇鍔″櫒鍚姩鑴氭湰鐩稿叧淇℃伅銆傚叧浜庨厤缃湇鍔″櫒鐨勪俊鎭弬瑙5.3鑺傦紝鈥渕ysqld锛歁ySQL鏈嶅姟鍣ㄢ銆
MySQL绋嬪簭閲囩敤鍚勭涓嶅悓鐨勯夐」銆備絾姣忎釜MySQL绋嬪簭鎻愪緵涓涓--help閫夐」,浣犲彲浠ョ敤鏉ユ煡闃呯▼搴忛夐」鐩稿叧璇存槑銆備緥濡傦紝浣犲彲浠ヨ瘯璇mysqld --help銆
浣犲彲浠ュ湪鍛戒护琛屼腑鎴栧湪閫夐」鏂囦欢涓寚瀹氶夐」鏉ユ浛鎹㈡墍鏈夋爣鍑嗙▼搴忎腑鐨勯粯璁ら夐」銆傚弬瑙4.3鑺傦紝鈥滄寚瀹氱▼搴忛夐」鈥銆
涓嬮潰绠鍗曟弿杩颁簡MySQL鏈嶅姟鍣ㄥ拰鏈嶅姟鍣ㄧ浉鍏崇▼搴忥細
路 mysqld
SQL鍚庡彴绋嬪簭(鍗MySQL鏈嶅姟鍣)銆傝鎯充娇鐢ㄥ鎴风绋嬪簭锛岃绋嬪簭蹇呴』杩愯锛屽洜涓哄鎴风閫氳繃杩炴帴鏈嶅姟鍣ㄦ潵璁块棶鏁版嵁搴撱傚弬瑙5.3鑺傦紝鈥渕ysqld锛歁ySQL鏈嶅姟鍣ㄢ銆
路 mysqld-max
鍖呮嫭鏇村鐗规х殑涓涓湇鍔″櫒鐗堟湰銆傚弬瑙5.1.2鑺傦紝鈥渕ysqld-max鎵╁睍MySQL鏈嶅姟鍣ㄢ
路 mysqld_safe
鏈嶅姟鍣ㄥ惎鍔ㄨ剼鏈傚鏋mysqld-max瀛樺湪,mysqld_safe璇曞浘鍚姩瀹冿紝鍚﹀垯鍚姩mysqld銆傚弬瑙5.1.3鑺傦紝鈥渕ysqld_safe锛歁ySQL鏈嶅姟鍣ㄥ惎鍔ㄨ剼鏈銆
路 mysql.server
鏈嶅姟鍣ㄥ惎鍔ㄨ剼鏈傝鑴氭湰鐢ㄤ簬浣跨敤鍖呭惈涓虹壒瀹氱骇鍒殑杩愯鍚姩鏈嶅姟鐨勮剼鏈殑杩愯鐩綍鐨勭郴缁熴傚畠璋冪敤mysqld_safe鏉ュ惎鍔MySQL鏈嶅姟鍣ㄣ傚弬瑙5.1.4鑺傦紝鈥渕ysql.server锛歁ySQL鏈嶅姟鍣ㄥ惎鍔ㄨ剼鏈銆
路 mysqld_multi
鏈嶅姟鍣ㄥ惎鍔ㄨ剼鏈紝鍙互鍚姩鎴栧仠姝㈢郴缁熶笂瀹夎鐨勫涓湇鍔″櫒銆傚弬瑙5.1.5鑺傦紝鈥渕ysqld_multi锛氱鐞嗗涓狹ySQL鏈嶅姟鍣ㄧ殑绋嬪簭鈥
路 mysql_install_db
璇ヨ剼鏈敤榛樿鏉冮檺鍒涘缓MySQL鎺堟潈琛ㄣ傞氬父鍙槸鍦ㄧ郴缁熶笂棣栨瀹夎MySQL鏃舵墽琛屼竴娆°傚弬瑙2.9.2鑺傦紝鈥淯nix涓嬪畨瑁呭悗鐨勮繃绋嬧銆
路 mysql_fix_ privilege_tables
鍦ㄥ崌绾у畨瑁呭悗锛屽鏋滄柊鐗堟湰MySQL涓殑 鎺堟潈琛ㄦ湁鏇存敼锛屽垯浣跨敤璇ヨ剼鏈潵鏇存敼鎺堟潈琛ㄣ傚弬瑙2.10.2鑺傦紝鈥滃崌绾ф巿鏉冭〃鈥銆
鏈嶅姟鍣ㄤ富鏈轰笂杩樿繍琛屽叾瀹冨嚑涓▼搴忥細
路 myisamchk
鐢ㄦ潵鎻忚堪銆佹鏌ャ佷紭鍖栧拰缁存姢MyISAM琛ㄧ殑瀹炵敤宸ュ叿銆傚湪5.9.5鑺傦紝鈥渕yisamchk锛歁yISAM琛ㄧ淮鎶ゅ疄鐢ㄥ伐鍏封涓弿杩颁簡myisamchk銆
路 make_binary_distribution
璇ョ▼搴忓彲浠ョ敓鎴愮紪璇戣繃鐨MySQL鐨勪簩杩涘埗鐗堟湰銆傚彲浠ラ氳繃FTP涓婁紶鍒ftp.mysql.com鐨/pub/mysql/upload/锛屼緵鍏跺畠MySQL鐢ㄦ埛浣跨敤銆
路 mysqlbug
MySQL 缂洪櫡鎶ュ憡鑴氭湰銆傚畠鍙互鐢ㄦ潵鍚MySQL閭欢绯荤粺鍙戦佺己闄锋姤鍛娿(浣犱篃鍙互璁块棶http://bugs.mysql.com/鍦ㄧ嚎鍒涘缓缂洪櫡鎶ュ憡鏂囦欢銆傚弬瑙1.7.1.3鑺傦紝鈥滃浣曢氭姤缂洪櫡鍜岄棶棰樷锛銆
MySQL-Max鏈嶅姟鍣ㄦ槸mysqld MySQL鏈嶅姟鍣ㄧ殑涓涓増鏈紝鍖呭惈浜嗘洿澶氱殑鐗规с
璇ュ垎鍙戠増鐨勪娇鐢ㄥ彇鍐充簬浣犵殑骞冲彴锛
路 瀵逛簬Windows锛MySQL浜岃繘鍒跺垎鍙戠増鍖呮嫭鏍囧噯鏈嶅姟鍣 (mysqld.exe)鍜MySQL-Max鏈嶅姟鍣(mysqld-max.exe)锛屽洜姝や綘涓嶅啀闇瑕佷笓鐢ㄥ垎鍙戠増銆傚彧闇瑕佷娇鐢ㄤ竴涓父瑙Windows鍒嗗彂鐗堬紝鍙互浠http://dev.mysql.com/downloads/鑾峰緱銆傚弬瑙2.3鑺傦紝鈥滃湪Windows涓婂畨瑁匨ySQL鈥銆
路 瀵逛簬Linux锛屽鏋滀綘浣跨敤RPM鍒嗗彂鐗堝畨瑁MySQL锛岄鍏堜娇鐢ㄥ父瑙MySQL-server RPM鏉ュ畨瑁呮爣鍑mysqld鏈嶅姟鍣ㄣ傜劧鍚庝娇鐢MySQL-Max RPM鏉ュ畨瑁mysqld-max鏈嶅姟鍣ㄣMySQL-Max RPM鍋囧畾浣犲凡缁忓畨瑁呬簡甯歌鏈嶅姟鍣RPM銆傚叧浜Linux RPM杞欢鍖呯殑璇︾粏淇℃伅锛屽弬瑙2.4鑺傦紝鈥滃湪Linux涓嬪畨瑁匨ySQL鈥銆
路 鎵鏈夊叾瀹MySQL-Max鍒嗗彂鐗堝寘鍚竴涓mysqld鏈嶅姟鍣紝浣嗗叿鏈夋洿澶氱殑鐗规с
浣犲彲浠ヤ粠MySQL AB缃戝潃http://dev.mysql.com/downloads/鎵惧埌MySQL-Max浜岃繘鍒剁増鏈
MySQL AB浣跨敤涓嬮潰鐨configure閫夐」鏋勫缓MySQL-Max鏈嶅姟鍣細
路 --with-server-suffix=-max
璇ラ夐」涓mysqld鐗堟湰瀛楃涓叉坊鍔犱竴涓-max鍚庣紑銆
路 --with-innodb
璇ラ夐」鍚敤InnoDB瀛樺偍寮曟搸鏀寔銆MySQL-Max鏈嶅姟鍣ㄥ寘鎷InnoDB鏀寔銆傚湪MySQL 4.0鍙婁互涓婄増鏈腑锛岄粯璁InnoDB鍖呮嫭鍦ㄦ墍鏈変簩杩涘埗鍒嗗彂鐗堜腑锛屽洜姝や綘涓嶉渶瑕佺敤MySQL-Max鏈嶅姟鍣ㄥ彧鏄敤鏉ヨ幏鍙InnoDB鏀寔銆
路 --with-bdb
璇ラ夐」鍚敤Berkeley DB (BDB)瀛樺偍寮曟搸鏀寔銆
路 --with-blackhole-storage-engine
璇ラ夐」鍚敤BLACKHOLE瀛樺偍寮曟搸鏀寔銆
路 USE_SYMDIR
鍚敤璇ュ畾涔夋潵涓Windows鎵撳紑鏁版嵁搴撶鍙烽摼鎺ユ敮鎸併傜鍙烽摼鎺ユ敮鎸侀傜敤浜庢墍鏈Windows鏈嶅姟鍣紝鍥犳Max鏈嶅姟鍣ㄤ笉闇瑕佹敮鎸佽鐗规с
路 --with-ndbcluster
璇ラ夐」鍚敤NDB Cluster瀛樺偍寮曟搸鏀寔銆傜洰鍓(5.1.2-alpha)鍙湁Linux銆Solaris鍜Mac OS X鏀寔Cluster銆傚凡鏈変竴浜涚敤鎴锋姤鍛婂湪BSD 鎿嶄綔绯荤粺涓婃垚鍔熶娇鐢ㄤ簡浠庢簮鐮佹瀯寤虹殑MySQL Cluster锛屼絾鐩墠杩樻病鏈夊緱鍒板畼鏂规敮鎸併
MySQL-Max浜岃繘鍒跺垎鍙戠増瀵逛簬鎯宠瀹夎棰勭紪璇戠▼搴忕殑鐢ㄦ埛寰堟柟渚裤傚鏋滀綘浣跨敤婧愮爜鍒嗗彂鐗堟瀯寤MySQL锛屼綘鍙互閫氳繃鍦ㄩ厤缃椂鍚敤MySQL-Max浜岃繘鍒跺垎鍙戠増鏋勫缓鎵鐢ㄧ殑鐩稿悓鐨勭壒鎬ф潵鏋勫缓浣犺嚜宸辩殑Max-like鏈嶅姟鍣ㄣ
MySQL-Max鏈嶅姟鍣ㄥ寘鎷BerkeleyDB (BDB)瀛樺偍寮曟搸锛屼絾骞堕潪鎵鏈夊钩鍙版敮鎸BDB銆
Solaris銆Mac OS X鍜Linux(鍦ㄥぇ澶氭暟骞冲彴涓)鐨MySQL-Max鏈嶅姟鍣ㄥ寘鎷NDB CLUSTER瀛樺偍寮曟搸鏀寔銆傝娉ㄦ剰蹇呴』鐢ndbcluster閫夐」鍚姩鏈嶅姟鍣紝浠ヤ究浣挎湇鍔″櫒鍋氫负MySQL Cluster鐨勪竴閮ㄥ垎鏉ヨ繍琛屻(璇︾粏淇℃伅鍙傝17.4鑺傦紝鈥淢ySQL绨囩殑閰嶇疆鈥锛銆
涓嬮潰鐨勮〃鏄剧ず浜MySQL-Max浜岃繘鍒跺湪鍝釜骞冲彴涓婂寘鎷BDB鍜/鎴NDB CLUSTER鏀寔锛
绯荤粺 |
BDB鏀寔 |
NDB鏀寔 |
AIX 4.3 |
N |
N |
HP-UX 11.0 |
N |
N |
Linux-Alpha |
N |
Y |
Linux-IA-64 |
N |
N |
Linux-Intel |
Y |
Y |
Mac OS X |
N |
N |
NetWare |
N |
N |
SCO OSR5 |
Y |
N |
Solaris-SPARC |
Y |
Y |
Solaris-Intel |
N |
Y |
UnixWare |
Y |
N |
Windows NT/2000/XP |
Y |
N |
瑕佹兂鎵惧嚭浣犵殑鏈嶅姟鍣ㄦ敮鎸佸摢涓瓨鍌ㄥ紩鎿庯紝鎵ц涓嬮潰鐨勮鍙ワ細
mysql> SHOW ENGINES;
+------------+---------+----------------------------------------------------------------+
| Engine | Support | Comment |
+------------+---------+----------------------------------------------------------------+
| MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables |
| HEAP | YES | Alias for MEMORY |
| MERGE | YES | Collection of identical MyISAM tables |
| MRG_MYISAM | YES | Alias for MERGE |
| ISAM | NO | Obsolete storage engine, now replaced by MyISAM |
| MRG_ISAM | NO | Obsolete storage engine, now replaced by MERGE |
| InnoDB | YES | Supports transactions, row-level locking, and foreign keys |
| INNOBASE | YES | Alias for INNODB |
| BDB | YES | Supports transactions and page-level locking |
| BERKELEYDB | YES | Alias for BDB |
| NDBCLUSTER | NO | Clustered, fault-tolerant, memory-based tables |
| NDB | NO | Alias for NDBCLUSTER |
| EXAMPLE | NO | Example storage engine |
| ARCHIVE | YES | Archive storage engine |
| CSV | NO | CSV storage engine |
| FEDERATED | YES | Federated MySQL storage engine |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) |
+------------+---------+----------------------------------------------------------------+
18 rows in set (0.00 sec)
(鍙﹀弬瑙13.5.4.8鑺傦紝鈥淪HOW ENGINES璇硶鈥锛銆
浣犺繕鍙互浣跨敤涓嬮潰鐨勮鍙ヤ唬鏇SHOW ENGINES锛屽苟妫鏌ヤ綘鎰熷叴瓒g殑瀛樺偍寮曟搸鐨勫彉閲忓硷細
mysql> SHOW VARIABLES LIKE 'have%';
+-----------------------+----------+
| Variable_name | Value |
+-----------------------+----------+
| have_archive | YES |
| have_bdb | NO |
| have_blackhole_engine | YES |
| have_compress | YES |
| have_crypt | YES |
| have_csv | YES |
| have_example_engine | NO |
| have_federated_engine | NO |
| have_geometry | YES |
| have_innodb | YES |
| have_isam | NO |
| have_ndbcluster | DISABLED |
| have_openssl | NO |
| have_partition_engine | YES |
| have_query_cache | YES |
| have_raid | NO |
| have_rtree_keys | YES |
| have_symlink | YES |
+-----------------------+----------+
18 rows in set (0.01 sec)
SHOW鍛戒护鐨勭簿纭緭鍑洪殢浣跨敤鐨MySQL鐗堟湰(鍜屽惎鐢ㄧ殑鐗规)鐨勪笉鍚岃屾湁鍙樺寲銆傜2鍒楃殑鍊艰〃绀哄悇鐗规ф敮鎸佺殑鏈嶅姟鍣ㄧ骇鍒紝濡備笅鎵绀猴細
鍊 |
鍚箟 |
YES |
鏀寔璇ョ壒鎬у苟宸茬粡婵娲汇 |
NO |
涓嶆敮鎸佽鐗规с |
DISABLED |
鏀寔璇ョ壒鎬т絾琚鐢ㄣ |
NO鍊艰〃绀虹紪璇戠殑鏈嶅姟鍣ㄤ笉鏀寔璇ョ壒鎬э紝鍥犳鍦ㄨ繍琛屾椂涓嶈兘婵娲汇
鍑虹幇DISABLED鍊兼槸鍥犱负鏈嶅姟鍣ㄥ惎鍔ㄦ椂璇ョ壒鎬ц绂佺敤锛屾垨娌℃湁缁欏嚭鍚敤瀹冪殑鎵鏈夐夐」銆傚湪鍚庝竴绉嶆儏鍐碉紝host_鍚.err閿欒鏃ュ織鏂囦欢搴斿寘鍚閫夐」琚鐢ㄧ殑鍘熷洜銆
濡傛灉鏈嶅姟鍣ㄦ敮鎸InnoDB鎴BDB瀛樺偍寮曟搸锛屼綘杩樺彲浠ョ湅瑙DISABLED锛屼絾鍦ㄨ繍琛屽惎鍔ㄦ椂浣跨敤浜--skip-innodb鎴--skip-bdb閫夐」銆傚浜NDB CLUSTER瀛樺偍寮曟搸锛DISABLED琛ㄧず鏈嶅姟鍣ㄦ敮鎸MySQL Cluster锛屼絾鍚姩鏃舵湭鍚敤--ndb-cluster閫夐」銆
鎵鏈MySQL鏈嶅姟鍣ㄦ敮鎸MyISAM琛紝鍥犱负MyISAM鏄 榛樿瀛樺偍寮曟搸銆
鍦Unix鍜NetWare涓帹鑽愪娇鐢mysqld_safe鏉ュ惎鍔mysqld鏈嶅姟鍣銆mysqld_safe澧炲姞浜嗕竴浜涘畨鍏ㄧ壒鎬э紝渚嬪褰撳嚭鐜伴敊璇椂閲嶅惎鏈嶅姟鍣ㄥ苟鍚戦敊璇棩蹇楁枃浠跺啓鍏ヨ繍琛屾椂闂翠俊鎭傛湰鑺傚悗闈㈠垪鍑轰簡NetWare鐨勭壒瀹氳涓恒
娉閲婏細涓轰簡淇濇寔鍚屾棫鐗堟湰MySQL鐨勫悜鍚庡吋瀹规э紝MySQL浜岃繘鍒跺垎鍙戠増浠嶇劧鍖呮嫭safe_mysqld浣滀负mysqld_safe鐨勭鍙烽摼鎺ャ備絾鏄紝浣犱笉搴斿啀渚濊禆瀹冿紝鍥犱负鍐嶅皢鏉ュ皢鍒犳帀瀹冦
榛樿鎯呭喌涓嬶紝mysqld_safe灏濊瘯鍚姩鍙墽琛mysqld-max锛堝鏋滃瓨鍦級锛屽惁鍒欏惎鍔mysqld銆傝琛屼负鐨勫惈涔夋槸锛
路 鍦Linux涓紝MySQL-Max RPM渚濊禆璇mysqld_safe鐨勮涓恒RPM瀹夎鍙墽琛mysqld-max锛屼娇mysqld_safe浠庤鐐硅捣鑷姩浣跨敤鍙墽琛屽懡浠ゃ
路 濡傛灉浣犲畨瑁呭寘鎷mysqld-max鏈嶅姟鍣ㄧ殑MySQL-Max鍒嗗彂鐗堬紝鍚庨潰鍗囩骇鍒伴潪-Max鐨MySQL鐗堟湰锛mysqld_safe浠嶇劧璇曞浘杩愯鏃х殑 mysqld-max鏈嶅姟鍣銆傚崌绾ф椂锛屼綘搴旀墜鍔ㄥ垹闄ゆ棫鐨mysqld-max鏈嶅姟鍣浠ョ‘淇mysqld_safe杩愯鏂扮殑mysqld鏈嶅姟鍣銆
瑕佹兂瓒婅繃榛樿琛屼负骞舵樉寮忔寚瀹氫綘鎯宠杩愯鍝釜鏈嶅姟鍣紝涓mysqld_safe鎸囧畾--mysqld鎴--mysqld-version閫夐」銆
mysqld_safe鐨勮澶氶夐」涓mysqld鐨勭浉鍚岀殑銆傚弬瑙5.3.1鑺傦紝鈥mysqld鍛戒护琛岄夐」鈥銆
鎵鏈夊湪鍛戒护琛屼腑涓mysqld_safe鎸囧畾鐨勯夐」琚紶閫掔粰mysqld銆濡傛灉浣犳兂瑕佷娇鐢mysqld涓嶆敮鎸佺殑mysqld_safe鐨閫夐」锛屼笉瑕佸湪鍛戒护琛屼腑鎸囧畾銆傜浉鍙嶏紝鍦ㄩ夐」鏂囦欢鐨[mysqld_safe]缁勫唴灏嗗畠浠垪鍑烘潵銆傚弬瑙4.3.2鑺傦紝鈥滀娇鐢ㄩ夐」鏂囦欢鈥銆
mysqld_safe浠庨夐」鏂囦欢鐨[mysqld]銆[server]鍜[mysqld_safe]閮ㄥ垎璇诲彇鎵鏈夐夐」銆備负浜嗕繚璇佸悜鍚庡吋瀹规э紝瀹冭繕璇诲彇 [safe_mysqld]閮ㄥ垎锛屽敖绠″湪MySQL 5.1瀹夎涓綘搴斿皢杩欓儴鍒嗛噸鏂板懡鍚嶄负[mysqld_safe]銆
mysqld_safe鏀寔涓嬮潰鐨勯夐」锛
路 --help
鏄剧ず甯姪娑堟伅骞堕鍑恒
路 --autoclose
(鍙湪NetWare涓)鍦NetWare涓紝mysqld_safe鍙互淇濇寔绐楀彛銆傚綋浣犲叧鎺mysqld_safe NLM鏃讹紝绐楀彛涓嶆寜榛樿璁剧疆娑堝け銆傜浉鍙嶏紝瀹冩彁绀虹敤鎴疯緭鍏ワ細
*<NLM has terminated; Press any key to close the screen>*
濡傛灉浣犳兂璁NetWare鑷姩鍏抽棴绐楀彛锛屽湪mysqld_safe涓娇鐢--autoclose閫夐」銆
路 --basedir=path
MySQL瀹夎鐩綍鐨勮矾寰勩
路 --core-file-size=size
mysqld鑳藉鍒涘缓鐨勫唴鏍告枃浠剁殑澶у皬銆傞夐」鍊间紶閫掔粰ulimit -c銆
路 --datadir=path
鏁版嵁鐩綍鐨勮矾寰勩
路 --defaults-extra-file=path
闄や簡閫氱敤閫夐」鏂囦欢鎵璇诲彇鐨勯夐」鏂囦欢鍚嶃傚鏋滅粰鍑猴紝蹇呴』棣栭夎閫夐」銆
路 --defaults-file=path
璇诲彇鐨勪唬鏇块氱敤閫夐」鏂囦欢鐨勯夐」鏂囦欢鍚嶃傚鏋滅粰鍑猴紝蹇呴』棣栭夎閫夐」銆
路 --ledir=path
鍖呭惈mysqld绋嬪簭鐨勭洰褰曠殑璺緞銆備娇鐢ㄨ閫夐」鏉ユ樉寮忚〃绀烘湇鍔″櫒浣嶇疆銆
路 --log-error=path
灏嗛敊璇棩蹇楀啓鍏ョ粰瀹氱殑鏂囦欢銆傚弬瑙5.11.1鑺傦紝鈥滈敊璇棩蹇椻銆
路 --mysqld=prog_name
鎯宠鍚姩鐨勬湇鍔″櫒绋嬪簭鍚(鍦ledir鐩綍)銆傚鏋滀綘浣跨敤MySQL浜岃繘鍒跺垎鍙戠増浣嗘湁浜岃繘鍒跺垎鍙戠増涔嬪鐨勬暟鎹洰褰曢渶瑕佽閫夐」銆
路 --mysqld-version =suffix
璇ラ夐」绫讳技--mysqld閫夐」锛屼絾浣犲彧鎸囧畾鏈嶅姟鍣ㄧ▼搴忓悕鐨勫悗缂銆傚熀鏈悕鍋囧畾涓mysqld銆渚嬪锛屽鏋滀綘浣跨敤--mysqld-version =max锛mysqld_safe鍚姩ledir鐩綍涓殑mysqld-max绋嬪簭銆傚鏋--mysqld-version鐨勫弬鏁颁负绌猴紝mysqld_safe浣跨敤鐩綍涓殑mysqld銆
路 --nice=priority
浣跨敤nice绋嬪簭鏍规嵁缁欏畾鍊兼潵璁剧疆鏈嶅姟鍣ㄧ殑璋冨害浼樺厛绾с
路 --no-defaults
涓嶈璇讳换浣曢夐」鏂囦欢銆傚鏋滅粰鍑猴紝蹇呴』棣栭夎閫夐」銆
路 --open-files-limit=count
mysqld鑳藉鎵撳紑鐨勬枃浠剁殑鏁伴噺銆傞夐」鍊间紶閫掔粰 ulimit -n銆傝娉ㄦ剰浣犻渶瑕佺敤root鍚姩mysqld_safe鏉ヤ繚璇佹纭伐浣滐紒
路 --pid-file=path
杩涚▼ID鏂囦欢鐨勮矾寰勩
路 --port=port_num
鐢ㄦ潵甯у惉TCP/IP杩炴帴鐨勭鍙e彿銆傜鍙e彿蹇呴』涓1024鎴栨洿澶у硷紝闄ら潪MySQL浠root绯荤粺鐢ㄦ埛杩愯銆
路 --skip-character-set-client-handshake
蹇界暐瀹㈡埛绔彂閫佺殑瀛楃闆嗕俊鎭紝浣跨敤鏈嶅姟鍣ㄧ殑榛樿瀛楃闆嗐(閫夋嫨璇ラ夐」锛MySQL鐨勫姩浣滀笌MySQL 4.0鐩稿悓锛銆
路 --socket=path
鐢ㄤ簬鏈湴杩炴帴鐨Unix濂楁帴瀛楁枃浠躲
路 --timezone=zone
涓虹粰瀹氱殑閫夐」鍊艰缃TZ鏃跺尯鐜鍙橀噺銆備粠鎿嶄綔绯荤粺鏂囨。鏌ラ槄鍚堟硶鐨勬椂鍖鸿瀹氭牸寮忋
路 --user={user_name | user_id}
浠ョ敤鎴峰悕user_name鎴栨暟瀛楃敤鎴ID user_id杩愯mysqld鏈嶅姟鍣銆(鏈枃涓殑鈥鐢ㄦ埛鈥濇寚绯荤粺鐧诲綍璐︽埛锛岃屼笉鏄 鎺堟潈琛ㄤ腑鐨MySQL鐢ㄦ埛锛銆
鎵цmysqld_safe鏃讹紝蹇呴』鍏堢粰鍑--defaults-file鎴--defaults-extra-option锛屾垨涓嶄娇鐢ㄩ夐」鏂囦欢銆備緥濡傦紝璇ュ懡浠ゅ皢涓嶄娇鐢ㄩ夐」鏂囦欢锛
mysqld_safe --port=port_num --defaults-file=file_name
鐩稿弽锛屼娇鐢ㄤ笅闈㈢殑鍛戒护锛
mysqld_safe --defaults-file=file_name --port=port_num
涓鑸儏鍐mysqld_safe鑴氭湰鍙互鍚姩浠庢簮鐮佹垨浜岃繘鍒MySQL鍒嗗彂鐗堝畨瑁呯殑鏈嶅姟鍣紝鍗充娇杩欎簺鍒嗗彂鐗堝皢鏈嶅姟鍣ㄥ畨瑁呭埌绋嶅井涓嶅悓鐨勪綅缃(鍙傝2.1.5鑺傦紝鈥滃畨瑁呭竷灞鈥锛銆 mysqld_safe鏈熸湜涓嬮潰鐨勫叾涓竴涓潯浠舵槸鐪熺殑锛
路 鍙互鏍规嵁璋冪敤mysqld_safe鐨勭洰褰曟壘鍒版湇鍔″櫒鍜屾暟鎹簱銆傚湪浜岃繘鍒跺垎鍙戠増涓紝mysqld_safe鐪嬩笂鍘诲湪bin鍜data鐩綍鐨勫伐浣滅洰褰曚笅銆傚浜庢簮鐮佸垎鍙戠増锛屼负libexec鍜var鐩綍銆傚鏋滀綘浠MySQL瀹夎鐩綍鎵цmysqld_safe搴旀弧瓒宠鏉′欢(渚嬪锛屼簩杩涘埗鍒嗗彂鐗堜负/usr/local/mysql)銆
路 濡傛灉涓嶈兘鏍规嵁宸ヤ綔鐩綍鎵惧埌鏈嶅姟鍣ㄥ拰鏁版嵁搴擄紝mysqld_safe璇曞浘閫氳繃缁濆璺緞瀵瑰畠浠畾浣嶃傚吀鍨嬩綅缃负/usr/local/libexec鍜/usr/local/var銆傚疄闄呬綅缃敱鏋勫缓鍒嗗彂鐗堟椂閰嶇疆鐨勫肩‘瀹氬鏋MySQL瀹夎鍒伴厤缃椂鎸囧畾鐨勪綅缃紝瀹冧滑搴旇鏄纭殑銆
鍥犱负mysqld_safe璇曞浘閫氳繃宸ヤ綔鐩綍鎵惧埌鏈嶅姟鍣ㄥ拰鏁版嵁搴擄紝鍙浣犱粠MySQL瀹夎鐩綍杩愯mysqld_safe锛鍙互灏MySQL浜岃繘鍒跺垎鍙戠増瀹夎鍒板叾瀹冧綅缃細
shell> cd mysql_installation_directory
shell> bin/mysqld_safe &
濡傛灉mysqld_safe澶辫触锛屽嵆浣夸粠MySQL瀹夎鐩綍璋冪敤浠嶇劧澶辫触锛屼綘鍙互鎸囧畾--ledir鍜--datadir閫夐」鏉ユ寚绀烘湇鍔″櫒鍜屾暟鎹簱鍦ㄤ綘鐨勭郴缁熶腑鐨勫畨瑁呯洰褰曘
涓鑸儏鍐碉紝浣犱笉搴旂紪杈mysqld_safe鑴氭湰銆傜浉鍙嶏紝搴斾娇鐢ㄥ懡浠よ閫夐」鎴my.cnf閫夐」鏂囦欢鐨[mysqld_safe]閮ㄥ垎鐨勯夐」鏉ラ厤缃mysqld_safe銆備竴鑸笉闇瑕佺紪杈mysqld_safe鏉ユ纭惎鍔ㄦ湇鍔″櫒銆備絾鏄紝濡傛灉浣犵紪杈戯紝灏嗘潵鍗囩骇MySQL鍚庝細瑕嗙洊浣犱慨鏀圭殑mysqld_safe鐗堟湰锛屽洜姝や綘搴斿浣犱慨鏀圭殑鐗堟湰杩涜澶囦唤浠ヤ究灏嗘潵閲嶈銆
鍦NetWare涓紝mysqld_safe鏄竴涓NetWare Loadable Module (NLM)锛屼粠鍘Unix shell鑴氭湰绉绘銆傚畠鎵ц锛
1. 妫鏌ョ郴缁熷拰閫夐」銆
2. 妫鏌MyISAM琛ㄣ
3. 淇濇寔MySQL鏈嶅姟鍣ㄧ獥鍙c
4. 鍚姩骞剁洃瑙mysqld锛屽鏋滃洜閿欒缁堟鍒欓噸鍚
5. 灏mysqld鐨閿欒娑堟伅鍙戦佸埌鏁版嵁鐩綍涓殑host_name.err 鏂囦欢銆
6. 灏mysqld_safe鐨勫睆骞曡緭鍑哄彂閫佸埌鏁版嵁鐩綍涓殑host_name.safe鏂囦欢銆
鍦Unix涓殑MySQL鍒嗗彂鐗堝寘鎷mysql.server鑴氭湰銆傚畠鍙互鐢ㄤ簬浣跨敤System V-style杩愯鐩綍鏉ュ惎鍔ㄥ拰鍋滄绯荤粺鏈嶅姟鐨勭郴缁燂紝渚嬪Linux鍜Solaris銆傚畠杩樼敤浜MySQL鐨Mac OS X Startup Item銆
mysql.server浣嶄簬MySQL婧愮爜鏍MySQL瀹夎鐩綍涓嬬殑support-files鐩綍涓
濡傛灉浣犱娇鐢Linux 鏈嶅姟鍣RPM杞欢鍖(MySQL-server-VERSION.rpm)锛mysql.server鑴氭湰灏嗗畨瑁呭埌/etc/init.d鐩綍涓嬶紝鍚嶄负mysql銆備綘涓嶉渶瑕 鎵嬪姩瀹夎銆傚叧浜Linux RPM杞欢鍖呯殑璇︾粏淇℃伅鍙傝2.4鑺傦紝鈥滃湪Linux涓嬪畨瑁匨ySQL鈥銆
涓浜涘崠鏂规彁渚涚殑RPM杞欢鍖呭畨瑁呯殑鍚姩鑴氭湰鐢ㄥ叾瀹冨悕锛屼緥濡mysqld銆
濡傛灉浣犱粠涓嶈嚜鍔ㄥ畨瑁mysql.server鐨勬簮鐮佸垎鍙戠増鎴栦簩杩涘埗鍒嗗彂鐗堟牸寮忓畨瑁MySQL锛屼篃鍙互鎵嬪姩瀹夎銆傜浉鍏宠鏄庡弬瑙2.9.2.2鑺傦紝鈥滆嚜鍔ㄥ惎鍔ㄥ拰鍋滄MySQL鈥銆
mysql.server浠 [mysql.server]鍜岄夐」鏂囦欢鐨[mysqld]閮ㄥ垎璇诲彇閫夐」銆(涓轰簡淇濊瘉鍚戝悗鍏煎鎬э紝瀹冭繕璇诲彇 [safe_mysqld]閮ㄥ垎锛屽敖绠″湪MySQL 5.1瀹夎涓綘搴斿皢杩欓儴鍒嗛噸鏂板懡鍚嶄负[mysqld_safe]锛銆
mysqld_multi鍙互绠$悊澶氫釜甯у惉涓嶅悓Unix濂楁帴瀛楁枃浠跺拰TCP/IP绔彛鐨勮繛鎺ョ殑mysqld 杩涚▼銆傚畠鍙互鍚姩鎴栧仠姝㈡湇鍔″櫒锛屾垨鎶ュ憡瀹冧滑鐨勫綋鍓嶇姸鎬併
绋嬪簭瀵绘壘my.cnf涓殑[mysqldN]缁(鎴--config-file閫夐」鎸囧畾鐨勬枃浠)銆N 鍙互涓轰换浣曟鏁存暟銆傚湪涓嬮潰鐨勮璁轰腑璇ユ暟瀛楁寚閫夐」缁勫彿锛屾垨GNR銆傜粍鍙峰尯鍒悇閫夐」缁勶紝骞剁敤浣mysqld_multi鐨勫弬鏁版潵鎸囧畾鎯宠鍚姩銆佸仠姝㈠摢涓湇鍔″櫒鎴栬幏鍙栧摢涓湇鍔″櫒鐨勭姸鎬佹姤鍛娿傝繖浜涚粍涓殑閫夐」涓庡皢鐢ㄦ潵鍚姩mysqld鐨[mysqld]缁勪腑鐨勭浉鍚屻(渚嬪锛屽弬瑙2.9.2.2鑺傦紝鈥滆嚜鍔ㄥ惎鍔ㄥ拰鍋滄MySQL鈥锛銆浣嗘槸锛屽綋浣跨敤澶氫釜鏈嶅姟鍣ㄦ椂锛岄渶瑕佹瘡涓湇鍔″櫒浣跨敤鑷繁鐨勯夐」鍊硷紝渚嬪Unix濂楁帴瀛楁枃浠跺拰TCP/IP绔彛鍙枫傚叧浜庡湪澶氭湇鍔″櫒鐜涓紝姣忎釜鏈嶅姟鍣ㄥ搴斿敮涓閫夐」鐨勮缁嗕俊鎭紝鍙傝5.12鑺傦紝鈥滃湪鍚屼竴鍙版満鍣ㄤ笂杩愯澶氫釜MySQL鏈嶅姟鍣ㄢ銆
瑕佹兂璋冪敤mysqld_multi锛屼娇鐢ㄤ笅闈㈢殑璇硶锛
shell> mysqld_multi [options] {start|stop|report} [GNR[,GNR] ...]
start銆stop鍜report琛ㄧず浣犳兂瑕佹墽琛岀殑鎿嶄綔銆備綘鍙互鍦ㄥ崟涓湇鍔″櫒鎴栧涓湇鍔″櫒涓婃墽琛屾寚瀹氱殑鎿嶄綔锛屽彇鍐充簬閫夐」鍚嶅悗闈㈢殑GNR 鍒椼傚鏋滄病鏈夎鍒楋紝mysqld_multi涓洪夐」鏂囦欢涓殑鎵鏈夋湇鍔″櫒鎵ц璇ユ搷浣溿
姣忎釜GNR鍊间唬琛ㄤ竴涓夐」缁勫彿鎴栫粍鍙疯寖鍥淬GNR鍊煎簲涓洪夐」鏂囦欢涓粍鍚嶆湯灏剧殑鍙枫備緥濡傦紝缁[mysqld17]鐨GNR涓17銆傝鎯虫寚瀹氱粍鍙风殑鑼冨洿锛岀敤鐮存姌鍙烽棿闅斿紑绗1涓拰鏈鍚1涓彿銆GNR鍊10-13浠h〃缁[mysqld10]鍒[mysqld13]銆傚彲浠ュ湪鍛戒护琛屼腑鎸囧畾澶氫釜缁勬垨缁勮寖鍥达紝鐢ㄩ楀彿闂撮殧寮銆GNR鍒椾笉鑳芥湁绌烘牸瀛楃(绌烘牸鎴tab)锛涚┖鏍煎瓧绗﹀悗闈㈢殑鍐呭灏嗚蹇界暐鎺夈
璇ュ懡浠や娇鐢ㄩ夐」缁[mysqld17]鍚姩鍗曚釜鏈嶅姟鍣細
shell> mysqld_multi start 17
璇ュ懡浠ゅ仠姝㈠涓湇鍔″櫒锛屼娇鐢ㄩ夐」缁[mysql8]鍜[mysqld10]鑷[mysqld13]锛
shell> mysqld_multi stop 8,10-13
浣跨敤璇ュ懡浠ゅ垪鍑鸿缃夐」鏂囦欢鐨勭ず渚嬶細
shell> mysqld_multi --example
mysqld_multi鏀寔涓嬮潰鐨勯夐」锛
路 --config-file=name
鎸囧畾閫夐」鏂囦欢鍚嶃傝繖鍏崇郴鍒mysqld_multi浠庡摢閲屽鎵[mysqldN]閫夐」缁勩傛病鏈夎閫夐」锛屼粠閫氱敤my.cnf鏂囦欢璇绘墍鏈夐夐」銆傞夐」涓嶅奖鍝 mysqld_multi浠庡摢閲岃鍙栬嚜宸辩殑閫夐」锛屾绘槸浠庨氱敤my.cnf鏂囦欢鐨[mysqld_multi]缁勮鍙栥
路 --example
鏄剧ず绀轰緥閫夐」鏂囦欢銆
路 --help
鏄剧ず甯姪娑堟伅骞堕鍑恒
路 --log=name
鎸囧畾鏃ュ織鏂囦欢鍚嶃傚鏋滆鏂囦欢瀛樺湪锛屽悗闈负鏃ュ織杈撳嚭銆
路 --mysqladmin=prog_name
鐢ㄦ潵鍋滄鏈嶅姟鍣ㄧ殑mysqladmin浜岃繘鍒躲
路 --mysqld=prog_name
鍙敤鐨mysqld浜岃繘鍒躲傝娉ㄦ剰浣犺繕鍙互灏嗚閫夐」鐨勫兼寚瀹氫负mysqld_safe銆傞夐」琚紶閫掔粰 mysqld銆纭繚鍦PATH鐜鍙橀噺璁惧畾鍊兼垨mysqld_safe涓湁mysqld鎵鍦ㄧ洰褰曘
路 --no-log
鎸夌収鏍囧噯杈撳嚭鎵撳嵃鏃ュ織淇℃伅锛屼笉瑕佸啓鍏ユ棩蹇楁枃浠躲傞粯璁ゆ儏鍐典笅锛岃緭鍑哄啓鍏ユ棩蹇楁枃浠躲
路 --password=password
璋冪敤mysqladmin鏃朵娇鐢ㄧ殑MySQL璐︽埛鐨勫瘑鐮併傝娉ㄦ剰璇ュ瘑鐮佸间笉鏄彲閫夐」锛屼笉璞″叾瀹MySQL绋嬪簭銆
路 --silent
绂佺敤璀﹀憡銆
路 --tcp-ip
閫氳繃TCP/IP绔彛鑰屼笉鏄Unix濂楁帴瀛楁枃浠舵潵杩炴帴姣忎釜MySQL鏈嶅姟鍣ㄣ(濡傛灉鎵句笉鍒板鎺ュ瓧鏂囦欢锛 鏈嶅姟鍣ㄤ粛鐒跺彲浠ヨ繍琛岋紝浣嗗彧鑳介氳繃 TCP/IP绔彛璁块棶锛銆榛樿鎯呭喌涓嬶紝浣跨敤Unix濂楁帴瀛楁枃浠惰繘琛岃繛鎺ャ傝閫夐」褰卞搷stop鍜report鎿嶄綔銆
路 --user=user_name
璋冪敤mysqladmin鏃朵娇鐢ㄧ殑MySQL璐︽埛鐨勭敤鎴峰悕銆
路 --verbose
鏇磋缁嗐
路 --version
鏄剧ず鐗堟湰淇℃伅骞堕鍑恒
鍏充簬mysqld_multi鐨勪竴浜涙敞瑙o細
路 纭繚鍋滄mysqld鏈嶅姟鍣(鐢mysqladmin绋嬪簭)鐨MySQL璐︽埛鍦ㄥ悇涓湇鍔″櫒涓殑鐢ㄦ埛鍚嶅拰瀵嗙爜鐩稿悓銆傚苟涓斿簲纭繚璐︽埛鍏锋湁SHUTDOWN鏉冮檺銆傚鏋滀綘鎯宠绠$悊鐨勬湇鍔″櫒鐨勭鐞嗚处鎴锋湁璁稿涓嶅悓鐨勭敤鎴峰悕鎴栧瘑鐮侊紝浣犻渶瑕佸湪姣忎釜鏈嶅姟鍣ㄤ笂鍒涘缓涓涓处鎴凤紝骞跺叿鏈夌浉鍚岀殑鐢ㄦ埛鍚嶅拰瀵嗙爜銆備緥濡傦紝浣犲彲浠ユ墽琛屼笅闈㈢殑鍛戒护涓烘瘡涓湇鍔″櫒璁剧疆涓涓櫘閫multi_admin璐︽埛锛
路 shell> mysql -u root -S /tmp/mysql.sock -proot_password
路 mysql> GRANT SHUTDOWN ON *.*
路 -> TO 'multi_admin'@'localhost' IDENTIFIED BY 'multipass'锛
鍙傝5.7.2鑺傦紝鈥滄潈闄愮郴缁熷伐浣滃師鐞嗏銆備綘蹇呴』涓烘瘡涓mysqld鏈嶅姟鍣ㄦ墽琛岃鎿嶄綔銆傚綋杩炴帴鏃堕傚綋鏇存敼杩炴帴鍙傛暟銆傝娉ㄦ剰璐︽埛鍚嶇殑涓绘満閮ㄥ垎蹇呴』鍏佽浣犵敤multi_admin浠庝綘鎯宠杩愯mysqld_multi鐨勪富鏈鸿繘琛岃繛鎺ャ
路 濡傛灉浣犱娇鐢mysqld_safe鏉ュ惎鍔mysqld(渚嬪锛--mysqld=mysqld_safe)锛--pid-file閫夐」寰堥噸瑕併傛瘡涓mysqld搴旀湁鑷繁鐨勮繘绋ID鏂囦欢銆備娇鐢mysqld_safe鑰屼笉浣跨敤mysqld鐨勫ソ澶勬槸mysqld_safe鈥瀹堟姢鈥濆叾mysqld杩涚▼锛屽鏋滅敤kill 鈥9鍙戦佺殑淇″彿鎴栫敱浜庡叾瀹冨師鍥狅紙渚嬪鍒嗘鏁呴殰锛夎繘绋嬬粓姝紝鍒欓噸鍚繘绋嬨傝娉ㄦ剰mysqld_safe鑴氭湰闇瑕佷綘浠庢煇涓綅缃惎鍔ㄥ畠銆傝繖璇存槑杩愯mysqld_multi鍓嶄綘蹇呴』杩涘叆鏌愪釜鐩綍銆傚鏋滃惎鍔ㄦ椂鏈夐棶棰橈紝璇峰弬瑙mysqld_safe鑴氭湰銆傜壒鍒槸瑕佹鏌ヤ笅鍒楄锛
路 ----------------------------------------------------------------
路 MY_PWD=`pwd`
路 # Check if we are starting this relative (for the binary release)
路 if test -d $MY_PWD/data/mysql -a -f ./share/mysql/english/errmsg.sys -a \
路 -x ./bin/mysqld
路 ----------------------------------------------------------------
鍙傝5.1.3鑺傦紝鈥渕ysqld_safe锛歁ySQL鏈嶅姟鍣ㄥ惎鍔ㄨ剼鏈銆備笂杩拌鎵ц鐨勬祴璇曞簲鎴愬姛锛屽惁鍒欎綘鍙兘閬囧埌浜嗛棶棰樸
路 姣忎釜mysqld鐨Unix濂楁帴瀛楁枃浠跺拰TCP/IP绔彛鍙峰繀椤讳笉鍚屻
路 浣犲彲鑳芥兂瑕佷负mysqld浣跨敤--user閫夐」锛屼絾涓烘浣犻渶瑕佺敤Unix root鐢ㄦ埛杩愯mysqld_multi鑴氭湰銆傞夐」鏂囦欢涓湁閫夐」涓嶈绱э紱濡傛灉浣犱笉鏄秴绾х敤鎴凤紝骞朵笖浣犵敤鑷繁鐨Unix璐︽埛閲嶅惎mysqld杩涚▼锛屼綘鍙細寰楀埌璀﹀憡銆
路 閲嶈锛氱‘淇mysqld杩涚▼鍚姩鎵鐢Unix璐︽埛鍙互瀹屽叏璁块棶鏁版嵁鐩綍銆涓嶈浣跨敤Unix root璐︽埛锛岄櫎闈炰綘鐭ラ亾浣犲湪鍋氫粈涔堛
路 闈炲父閲嶈锛氫娇鐢mysqld_multi鍓嶏紝纭繚鐞嗚В浼犻掔粰mysqld鏈嶅姟鍣ㄧ殑閫夐」鐨勫惈涔変互鍙婁綘涓轰粈涔鎯宠鐙珛鐨mysqld杩涚▼銆傚簲娓呮 鍦ㄧ浉鍚岀殑鏁版嵁鐩綍涓嬩娇鐢ㄥ涓mysqld鏈嶅姟鍣鐨勫嵄闄┿備娇鐢ㄥ崟鐙殑鏁版嵁鐩綍锛岄櫎闈炰綘鐭ラ亾浣犲湪鍋氫粈涔堛傚湪绾跨▼绯荤粺涓紝鍦ㄧ浉鍚岀殑鏁版嵁鐩綍涓嬪惎鍔ㄥ涓湇鍔″櫒涓嶄細寰楀埌瓒呮ц兘銆傚弬瑙5.12鑺傦紝鈥滃湪鍚屼竴鍙版満鍣ㄤ笂杩愯澶氫釜MySQL鏈嶅姟鍣ㄢ銆
涓嬮潰鐨勭ず渚嬫樉绀轰簡浣犲浣曡缃夐」鏂囦欢鏉ヤ娇鐢mysqld_multi銆備笓闂ㄧ渷鍘荤1涓拰绗5涓[mysqldN]缁勬潵璇存槑浣犵殑閫夐」鏂囦欢鍙互绋嶆湁涓嶅悓銆傝繖鏍风粰浣犳洿澶х殑鐏垫椿鎬сmysqld绋嬪簭閲嶅惎鎴栧仠姝㈢殑椤哄簭鐢卞畠浠湪閫夐」鏂囦欢涓殑椤哄簭鍐冲畾銆
# This file should probably be in your home dir (~/.my.cnf)
# or /etc/my.cnf
# Version 2.1 by Jani Tolonen
[mysqld_multi]
mysqld = /usr/local/bin/mysqld_safe
mysqladmin = /usr/local/bin/mysqladmin
user = multi_admin
password = multipass
[mysqld2]
socket = /tmp/mysql.sock2
port = 3307
pid-file = /usr/local/mysql/var2/hostname.pid2
datadir = /usr/local/mysql/var2
language = /usr/local/share/mysql/english
user = john
[mysqld3]
socket = /tmp/mysql.sock3
port = 3308
pid-file = /usr/local/mysql/var3/hostname.pid3
datadir = /usr/local/mysql/var3
language = /usr/local/share/mysql/swedish
user = monty
[mysqld4]
socket = /tmp/mysql.sock4
port = 3309
pid-file = /usr/local/mysql/var4/hostname.pid4
datadir = /usr/local/mysql/var4
language = /usr/local/share/mysql/estonia
user = tonu
[mysqld6]
socket = /tmp/mysql.sock6
port = 3311
pid-file = /usr/local/mysql/var6/hostname.pid6
datadir = /usr/local/mysql/var6
language = /usr/local/share/mysql/japanese
user = jani
MySQL瀹炰緥绠$悊鍣(IM)鏄氳繃TCP/IP绔彛杩愯鐨勫悗鍙扮▼搴忥紝鐢ㄦ潵鐩戣鍜岀鐞MySQL鏁版嵁搴撴湇鍔″櫒瀹炰緥銆MySQL瀹炰緥绠$悊鍣 閫傚悎Unix-绫绘搷浣滅郴缁熷拰Windows銆
鍙互鍦mysqld_safe鑴氭湰浣跨敤MySQL瀹炰緥绠$悊鍣ㄦ潵鍚姩鍜屽仠姝MySQL鏈嶅姟鍣紝鐢氳嚦鍙互浠庝竴涓繙绋嬩富鏈銆MySQL瀹炰緥绠$悊鍣ㄨ繕鎵цmysqld_multi鑴氭湰鐨勫姛鑳(鍜屽ぇ澶氭暟璇硶)銆備笅闈负MySQL瀹炰緥绠$悊鍣ㄧ殑璇︾粏鎻忚堪銆
涓鑸儏鍐碉紝鐢mysql.server鑴氭湰鍚姩MySQL Database Server锛MySQL鏁版嵁搴撴湇鍔″櫒锛夛紝閫氬父椹荤暀鍦/etc/init.d/ 鏂囦欢澶广傞粯璁ゆ儏鍐典笅璇ヨ剼鏈皟鐢mysqld_safe鑴氭湰銆備絾鏄紝浣犲彲浠ュ湪鑴氭湰涓皢use_mysqld_safe鍙橀噺璁剧疆涓0(闆)浠ヤ究浣跨敤MySQL瀹炰緥绠$悊鍣ㄦ潵鍚姩鏈嶅姟鍣ㄣ
鍦ㄨ繖绉嶆儏鍐典笅锛Instance Manager鐨勮涓哄彇鍐充簬MySQL閰嶇疆鏂囦欢涓殑閫夐」銆傚鏋滄病鏈夐厤缃枃浠讹紝MySQL瀹炰緥绠$悊鍣ㄥ垱寤mysqld瀹炰緥骞惰瘯鍥剧敤榛樿(缂栬瘧宓屽叆鐨)閰嶇疆鏉ュ惎鍔ㄣ傝繖璇存槑濡傛灉mysqld娌℃湁瀹夎鍒 榛樿浣嶇疆锛IM涓嶈兘鐚滃嚭瀹冪殑浣嶇疆銆傚鏋滀綘宸茬粡鍦ㄩ潪鏍囧噯浣嶇疆瀹夎浜MySQL鏈嶅姟鍣紝浣犲簲浣跨敤閰嶇疆鏂囦欢銆傚弬瑙2.1.5鑺傦紝鈥滃畨瑁呭竷灞鈥銆
濡傛灉鏈夐厤缃枃浠讹紝IM灏嗗垎鏋愰厤缃枃浠舵悳绱[mysqld]閮ㄥ垎(渚嬪[mysqld]銆[mysqld1]銆[mysqld2]绛)銆傛瘡涓儴鍒嗘寚瀹氫竴涓疄渚嬨傚惎鍔ㄦ椂IM灏嗗惎鍔ㄦ墍鏈夋壘鍒扮殑瀹炰緥銆IM鍏抽棴鏃堕粯璁ゅ仠姝㈡墍鏈夊疄渚嬨
璇锋敞鎰忔湁涓涓壒娈婇夐」mysqld-path(mysqld-path = path-to-mysqld- binary)锛屽彧鑳界敤IM璇嗗埆銆備娇鐢ㄨ鍙橀噺璁IM鐭ラ亾mysqld浜岃繘鍒堕┗鐣欏湪鍝効銆備綘杩樺簲璇ヤ负鏈嶅姟鍣ㄨ缃basedir鍜datadir閫夐」銆
鍚敤MySQL瀹炰緥绠$悊鍣ㄧ殑鍏稿瀷MySQL鏈嶅姟鍣ㄥ惎鍔/鍏抽棴寰幆涓猴細
路 鐢/etc/init.d/mysql鑴氭湰鍚姩MySQL瀹炰緥绠$悊鍣ㄣ
路 MySQL瀹炰緥绠$悊鍣ㄥ惎鍔ㄦ墍鏈夊疄渚嬪苟鐩戣瀹冧滑銆
路 濡傛灉鏌愪釜鏈嶅姟鍣ㄥ疄渚嬪け璐ワ紝MySQL瀹炰緥绠$悊鍣ㄩ噸鍚畠銆
路 濡傛灉MySQL瀹炰緥绠$悊鍣ㄨ鍏抽棴(渚嬪鐢/etc/init.d/mysql stop鍛戒护)锛屾墍鏈夊疄渚嬭MySQL瀹炰緥绠$悊鍣ㄥ叧闂
浣跨敤MySQL瀹㈡埛绔-鏈嶅姟鍣ㄥ崗璁潵澶勭悊鍚MySQL瀹炰緥绠$悊鍣ㄤ箣闂寸殑閫氫俊銆備綘涓嶈兘浣跨敤鏍囧噯mysql瀹㈡埛绔▼搴忓拰MySQL C API鏉ヨ繛鎺IM銆IM鏀寔瀹㈡埛绔伐鍏峰拰mysql-4.1鎴栦互鍚庣殑鐗堟湰鎵鍒嗗彂鐨勫簱鎵鐢ㄧ殑MySQL瀹㈡埛绔-鏈嶅姟鍣ㄥ崗璁増鏈
IM灏嗙敤鎴蜂俊鎭繚瀛樺埌瀵嗙爜鏂囦欢涓傚瘑鐮佹枃浠剁殑榛樿浣嶇疆涓/etc/mysqlmanager.passwd銆
瀵嗙爜搴旂被浼间簬锛
petr:*35110DC9B4D8140F5DE667E28C72DD2597B5C848
瑕佹兂鐢熸垚瀵嗙爜鐢--passwd閫夐」璋冪敤IM銆傚垯杈撳嚭鍙互閲嶅畾鍚戝埌/etc/mysqlmanager.passwd鏂囦欢浠ユ坊鍔犳柊鐢ㄦ埛銆備笅闈负绀轰緥鍛戒护銆
./mysqlmanager --passwd >> /etc/mysqlmanager.passwd
Creating record for new user.
Enter user name: mike
Enter password: <password>
Re-type password: <password>
涓嬮潰鐨勮灏嗗姞鍒/etc/mysqlmanager.passwd锛
mike:*00A51F3F48415C7D4E8908980D443C29C69B60C9
濡傛灉/etc/mysqlmanager.passwd鏂囦欢涓病鏈夎鏉★紝鍒欎笉鑳借繛鎺IM銆
路 --help锛-?
鏄剧ず甯姪娑堟伅骞堕鍑恒
路 --bind-address=name
缁戝畾鍦板潃鐢ㄤ簬杩炴帴銆
路 --default-mysqld-path=name
鍦Unix涓紝濡傛灉瀹炰緥閮ㄥ垎娌℃湁璺緞锛屽垯涓哄鎵MySQL鏈嶅姟鍣ㄤ簩杩涘埗鐨勫湴鐐广備緥濡傦細default-mysqld-path = /usr/sbin/mysqld
路 --defaults-file=file_name
浠庣粰瀹氭枃浠惰Instance Manager鍜MySQL鏈嶅姟鍣ㄨ瀹氬笺傛墍鏈Instance Manager鏇存敼鐨勯厤缃皢鍔犲叆璇ユ枃浠躲傚彧鑳界敤浜Instance Manager鐨勭涓閫夐」銆
路 --install
鍦Windows涓紝灏Instance Manager瀹夎涓Windows鏈嶅姟銆
路 --log=name
IM鏃ュ織鏂囦欢鐨勮矾寰勩傜粨鍚--run-as-service閫夐」浣跨敤銆
路 --monitoring-interval=Seconds
鐩戣瀹炰緥鐨勯棿闅旓紝鍗曚綅涓虹銆Instance Manager灏嗗皾璇曡繛鎺ユ瘡涓洃瑙嗙殑瀹炰緥鏉ユ鏌ュ畠浠槸鍚︽槸娲诲姩鐨/娌℃湁鎸傝捣銆傚嚭鐜版晠闅滐紝IM灏嗛噸鍚嚑娆(瀹為檯涓婃槸澶氭)瀹炰緥銆傚彲浠ョ敤nonguarded閫夐」涓虹壒瀹氬疄渚嬬鐢ㄨ琛屼负銆傚鏋滄湭缁欏畾浠讳綍鍊硷紝 榛樿浣跨敤20绉掋
路 --passwd锛-P
缂栧啓passwd鏂囦欢骞堕鍑恒
路 --password-file=name
浠庤鏂囦欢涓鎵Instance Manager鐢ㄦ埛鍜屽瘑鐮併傞粯璁ゆ枃浠舵槸/etc/mysqlmanager.passwd銆
路 --pid-file=name
浣跨敤鐨勮繘绋ID鏂囦欢銆傞粯璁ゆ儏鍐典笅锛岃鏂囦欢鏂囦欢鍚嶄负mysqlmanager.pid銆
路 -- port=port_num
鐢ㄤ簬杩炴帴鐨勭鍙e彿銆(IANA鍒嗛厤鐨 榛樿绔彛鍙蜂负2273)銆
路 --print-defaults
鎵撳嵃褰撳墠鐨勯粯璁ゅ煎苟閫鍑恒傚彧鑳界敤浣Instance Manager鐨勭涓閫夐」銆
路 --remove
鍦Windows涓紝鍒犳帀Instance Manager Windows鏈嶅姟銆傚亣瀹氬墠闈㈠凡缁忕敤--install杩愯浜Instance Manager銆
路 --run-as-service
浣垮畬鍠勮繘绋嬪彉涓哄悗鍙扮▼搴忓苟鍚姩銆傚畬鍠勮繘绋嬪緢绠鍗曪紝涓嶆槗宕╂簝銆傚嚭鐜版晠闅滃悗瀹冨皢鑷繁閲嶅惎IM銆
路 --socket=name
Unix涓敤浜庤繛鎺ョ殑濂楁帴瀛楁枃浠躲傞粯璁ゆ儏鍐典笅锛屾枃浠跺悕涓/tmp/mysqlmanager.sock銆
路 --standalone
鍦Windows涓互鍗曟満妯″紡杩愯Instance Manager銆
路 --user=name
鍚姩骞惰繍琛mysqlmanager鐨勭敤鎴峰悕銆傚缓璁娇鐢ㄨ繍琛mysqld鏈嶅姟鍣鐨勭敤鎴疯处鎴锋潵杩愯mysqlmanager銆
路 --version, -V
杈撳嚭鐗堟湰淇℃伅骞堕鍑恒
# MySQL Instance Manager options section
[manager]
default-mysqld-path = /usr/local/mysql/libexec/mysqld
socket=/tmp/manager.sock
pid-file=/tmp/manager.pid
password-file = /home/cps/.mysqlmanager.passwd
monitoring-interval = 2
port = 1999
bind-address = 192.168.1.5
MySQL瀹炰緥绠$悊鍣ㄥ彧鍦Unix涓鍙栧苟绠$悊/etc/my.cnf鏂囦欢銆傚湪Windows涓紝MySQL瀹炰緥绠$悊鍣ㄤ粠Instance Manager鐨勫畨瑁呯洰褰曡鍙my.ini鏂囦欢銆傜敤--defaults-file=file_ name閫夐」鍙互鏇存敼榛樿閫夐」鏂囦欢鐨勪綅缃
瀹炰緥閮ㄥ垎鎸囧畾鍚姩鏃剁粰姣忎釜瀹炰緥鐨勯夐」銆傝繖浜涗富瑕佹槸鏅MySQL鏈嶅姟鍣ㄩ夐」锛屼絾鏈変竴浜IM-涓撶敤閫夐」锛
路 mysqld-path = <path-to-mysqld-binary>
mysqld鏈嶅姟鍣浜岃繘鍒剁殑璺緞銆
路 shutdown-delay = Seconds
IM搴旂瓑寰呭疄渚嬪叧闂殑绉掓暟銆 榛樿涓35绉掋傝秴杩囧欢杩熸椂闂村悗锛IM鍋囧畾瀹炰緥姝f寕璧峰苟璇曞浘鈥kill 鈥9鈥瀹冦傚鏋滀綘浣跨敤甯large琛ㄧ殑InnoDB锛屼綘搴斿綋澧炲姞璇ュ笺
路 nonguarded
濡傛灉浣犳兂瑕佷负鏌愪釜瀹炰緥绂佺敤IM鐩戣鍔熻兘锛屽簲璁剧疆璇ラ夐」銆
涓嬮潰缁欏嚭浜嗗嚑涓疄渚嬬ず渚嬨
[mysqld]
mysqld-path=/usr/local/mysql/libexec/mysqld
socket=/tmp/mysql.sock
port=3307
server_id=1
skip-stack-trace
core-file
skip-bdb
log-bin
log-error
log=mylog
log-slow-queries
[mysqld2]
nonguarded
port=3308
server_id=2
mysqld-path= /home/cps/mysql/trees/mysql-5.1/sql/mysqld
socket = /tmp/mysql.sock5
pid-file = /tmp/hostname.pid5
datadir= /home/cps/mysql_data/data_dir1
language=/home/cps/mysql/trees/mysql-5.1/sql/share/english
log-bin
log=/tmp/fordel.log
路 START INSTANCE <instance_name>
璇ュ懡浠ゅ皢璇曞浘鍚姩涓涓疄渚嬶細
mysql> START INSTANCE mysqld4;
Query OK, 0 rows affected (0,00 sec)
路 STOP INSTANCE <instance_name>
灏嗚瘯鍥惧仠姝竴涓疄渚嬶細
mysql> STOP INSTANCE mysqld4;
Query OK, 0 rows affected (0,00 sec)
路 SHOW INSTANCES
鏄剧ず鎵鏈夎浇鍏ョ殑瀹炰緥鍚嶏細
mysql> show instances;
+---------------+---------+
| instance_name | status |
+---------------+---------+
| mysqld3 | offline |
| mysqld4 | online |
| mysqld2 | offline |
+---------------+---------+
3 rows in set (0,04 sec)
路 SHOW INSTANCE STATUS <instance_name>
鏄剧ず閫夊畾鐨勫疄渚嬬殑鐘舵佸拰鐗堟湰淇℃伅锛
mysql> SHOW INSTANCE STATUS mysqld3;
+---------------+--------+---------+
| instance_name | status | version |
+---------------+--------+---------+
| mysqld3 | online | unknown |
+---------------+--------+---------+
1 row in set (0.00 sec)
路 SHOW INSTANCE OPTIONS <instance_name>
鏄剧ず瀹炰緥浣跨敤鐨勯夐」锛
mysql> SHOW INSTANCE OPTIONS mysqld3;
+---------------+---------------------------------------------------+
| option_name | value |
+---------------+---------------------------------------------------+
| instance_name | mysqld3 |
| mysqld-path | /home/cps/mysql/trees/mysql-4.1/sql/mysqld |
| port | 3309 |
| socket | /tmp/mysql.sock3 |
| pid-file | hostname.pid3 |
| datadir | /home/cps/mysql_data/data_dir1/ |
| language | /home/cps/mysql/trees/mysql-4.1/sql/share/english |
+---------------+---------------------------------------------------+
7 rows in set (0.01 sec)
路 SHOW <instance_name> LOG FILES
璇ュ懡浠ゆ彁渚涘疄渚嬩娇鐢ㄧ殑鎵鏈夋棩蹇楁枃浠躲傜粨鏋滃寘鍚棩蹇楁枃浠剁殑璺緞鍜屾棩蹇楁枃浠剁殑澶у皬銆傚鏋滄病鏈夊湪閰嶇疆鏂囦欢涓寚瀹氭棩蹇楁枃浠剁殑璺緞 (渚嬪log=/var/mysql.log)锛IM璇曞浘鐚滃嚭瀹冪殑浣嶇疆銆傚鏋IM涓嶈兘鐚滃嚭鏃ュ織鏂囦欢鐨勪綅缃紝浣犲簲鏄庣‘鎸囧畾鏃ュ織鏂囦欢鐨勪綅缃
mysql> SHOW mysqld LOG FILES;
+-------------+------------------------------------+----------+
| Logfile | Path | Filesize |
+-------------+------------------------------------+----------+
| ERROR LOG | /home/cps/var/mysql/owlet.err | 9186 |
| GENERAL LOG | /home/cps/var/mysql/owlet.log | 471503 |
| SLOW LOG | /home/cps/var/mysql/owlet-slow.log | 4463 |
+-------------+------------------------------------+----------+
3 rows in set (0.01 sec)
路 SHOW <instance_name> LOG {ERROR | SLOW | GENERAL} size[,offset_from_end]
璇ュ懡浠ゆ煡鎵炬寚瀹氱殑鏃ュ織鏂囦欢鐨勪竴閮ㄥ垎銆傚洜涓哄ぇ澶氭暟鐢ㄦ埛鍏虫敞鏈鏂扮殑鏃ュ織娑堟伅锛岀敤size鍙傛暟瀹氫箟浣犳兂瑕佷粠鏃ュ織鏈熬寮濮嬬储鍙栫殑瀛楄妭鏁般備綘鍙互鎸囧畾鍙offset_from_end鍙傛暟浠庢棩蹇楁枃浠朵腑閮ㄧ储鍙栨暟鎹備笅闈㈢殑绀轰緥鍙互绱㈠彇21涓瓧鑺傜殑鏁版嵁锛屼粠鏃ュ織鏂囦欢鏈熬寮濮23涓瓧鑺傦紝2涓瓧鑺傜敤浜庣粨鏉燂細
mysql> SHOW mysqld LOG GENERAL 21, 2;
+---------------------+
| Log |
+---------------------+
| using password: YES |
+---------------------+
1 row in set (0.00 sec)
路 SET instance_name.option_name=option_value
璇ュ懡浠ょ紪杈戞寚瀹氱殑瀹炰緥鐨勯厤缃枃浠朵互鏇存敼/澧炲姞瀹炰緥閫夐」銆IM鍋囧畾閰嶇疆鏂囦欢浣嶄簬/etc/my.cnf銆備綘搴旀鏌ユ枃浠舵槸鍚﹀瓨鍦紝骞跺叿鏈夊悎閫傜殑鏉冮檺銆
mysql> SET mysqld2.port=3322;
Query OK, 0 rows affected (0.00 sec)
鍦MySQL鏈嶅姟鍣ㄩ噸鍚墠锛屽閰嶇疆鏂囦欢杩涜鐨勬洿鏀逛笉浼氱敓鏁堛傚苟涓旓紝鎵цFLUSH INSTANCES鍛戒护鍚庯紝鎵嶄細灏嗚繖浜涙洿鏀逛繚瀛樺埌Instance Manager鐨勫疄渚嬭瀹氬肩殑鏈湴缂撳瓨涓
路 UNSET instance_name.option_name
璇ュ懡浠や粠瀹炰緥鐨勯厤缃枃浠跺垹闄や竴涓夐」銆
mysql> UNSET mysqld2.port;
Query OK, 0 rows affected (0.00 sec)
鍦MySQL鏈嶅姟鍣ㄩ噸鍚墠锛屽閰嶇疆鏂囦欢杩涜鐨勬洿鏀逛笉浼氱敓鏁堛傚苟涓旓紝鎵цFLUSH INSTANCES鍛戒护鍚庯紝鎵嶄細灏嗚繖浜涙洿鏀逛繚瀛樺埌Instance Manager鐨勫疄渚嬭瀹氬肩殑鏈湴缂撳瓨涓
路 FLUSH INSTANCES
璇ュ懡浠ゅ己鍒IM閲嶈閰嶇疆鏂囦欢骞舵竻绌哄唴閮ㄧ粨鏋勩傜紪杈戦厤缃枃浠跺悗搴旀墽琛岃鍛戒护銆傝鍛戒护涓嶉噸鍚疄渚嬶細
mysql> FLUSH INSTANCES;
Query OK, 0 rows affected (0.04 sec)
褰撳惎鍔mysqld鏈嶅姟鍣鏃讹紝浣犲彲浠ヤ娇鐢4.3鑺傦紝鈥滄寚瀹氱▼搴忛夐」鈥涓弿杩扮殑鏂规硶鎸囧畾绋嬪簭閫夐」銆傛渶甯哥敤鐨勬柟娉曟槸鍦ㄩ夐」鏂囦欢涓垨鍦ㄥ懡浠よ鎻愪緵閫夐」銆備絾鏄紝鍦ㄥぇ澶氭暟鎯呭喌涓嬶紝甯屾湜鏈嶅姟鍣ㄦ瘡娆¤繍琛屾椂浣跨敤鐩稿悓鐨勯夐」銆傛渶濂界殑鏂规硶鏄‘淇濆皢瀹冧滑鍒楀湪閫夐」鏂囦欢涓傚弬瑙4.3.2鑺傦紝鈥滀娇鐢ㄩ夐」鏂囦欢鈥銆
mysqld浠[mysqld]鍜[server]缁勮鍙栭夐」銆mysqld_safe浠[mysqld]銆[server]銆[mysqld_safe]鍜[safe_mysqld]缁勮鍙栭夐」銆mysql.server浠 [mysqld]鍜[mysql.server]缁勮鍙栭夐」銆傚祵鍏ュ紡MySQL鏈嶅姟鍣ㄩ氬父浠[server]銆[embedded]鍜[xxxxx_SERVER]缁勮鍙栭夐」锛屽叾涓xxxxx鏄湇鍔″櫒宓屽叆鐨勫簲鐢ㄧ▼搴忓悕銆
mysqld鎺ュ彈璁稿鍛戒护琛岄夐」銆傛墽琛mysqld --help鍙互绠鍗曞垪鍑烘潵銆傝鎯崇湅鍏ㄩ儴鍒楄〃鍒楋紝浣跨敤鍛戒护mysqld --verbose --help銆
涓嬮潰鍒楀嚭浜嗕竴浜涙渶甯哥敤鐨勬湇鍔″櫒閫夐」銆傚叾瀹冪殑閫夐」鍦ㄥ叾瀹冨湴鏂规弿杩帮細
路 褰卞搷瀹夊叏鐨勯夐」锛氬弬瑙5.6.3鑺傦紝鈥淢ysqld瀹夊叏鐩稿叧鍚姩閫夐」鈥銆
路 SSL-鐩稿叧閫夐」锛氬弬瑙5.8.7.6鑺傦紝鈥淪SL鍛戒护琛岄夐」鈥銆
路 浜岃繘鍒舵棩蹇楁帶鍒堕夐」锛氬弬瑙5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆
路 澶嶅埗鐩稿叧閫夐」锛氬弬瑙6.8鑺傦紝鈥滃鍒跺惎鍔ㄩ夐」鈥銆
路 鐗瑰畾瀛樺偍寮曟搸鐩稿叧閫夐」锛氬弬瑙15.1.1鑺傦紝鈥淢yISAM鍚姩閫夐」鈥銆15.5.3鑺傦紝鈥淏DB鍚姩閫夐」鈥鍜15.2.4鑺傦紝鈥淚nnoDB鍚姩閫夐」鈥銆
浣犺繕鍙互灏嗗彉閲忓悕浣滀负涓涓夐」锛岃缃湇鍔″櫒绯荤粺鍙橀噺鐨勫硷紝濡傛湰鑺傚悗闈㈡墍杩般
路 --help锛-?
鏄剧ず绠鐭殑甯姪娑堟伅骞堕鍑恒備娇鐢--verbose鍜--help閫夐」鏉ョ湅鍏ㄩ儴鍐呭銆
路 --allow-suspicious-udfs
璇ラ夐」鎺у埗鏄惁鐢ㄦ埛瀹氫箟鐨勫嚱鏁板彧鏈変竴涓xxx绗︼紝鐢ㄤ綔鍙浇鍏ョ殑涓诲嚱鏁般傞粯璁ゆ儏鍐典笅锛岃閫夐」琚叧闂紝鍙湁鑷冲皯鏈変竴涓檮灞炵鐨UDF 鍙互杞藉叆銆傝繖鏍峰彲浠ラ槻姝粠鏈寘鍚悎娉UDF鐨勫叡浜枃浠惰杞藉嚱鏁般傚弬瑙27.2.3.6鑺傦紝鈥滅敤鎴峰畾涔夊嚱鏁板畨鍏ㄦ敞鎰忎簨椤光銆
路 --ansi
浣跨敤鏍囧噯(ANSI)SQL璇硶浠f浛MySQL璇硶銆傚弬瑙1.8.3鑺傦紝鈥滃湪ANSI妯″紡涓嬭繍琛孧ySQL鈥銆備娇鐢--sql-mode閫夐」鍙互鏇寸簿纭帶鍒舵湇鍔″櫒SQL妯″紡銆
路 --basedir=path, -b path
MySQL瀹夎鐩綍鐨勮矾寰勩傞氬父鎵鏈夎矾寰勬牴鎹璺緞鏉ヨВ鏋愩
路 --bind-address=IP
寰呯粦瀹氱殑IP鍦板潃銆
路 --bootstrap
mysql_install_db鑴氭湰浣跨敤璇ラ夐」鏉ュ垱寤MySQL鎺堟潈琛紝涓嶉渶瑕佸惎鍔MySQL鏈嶅姟鍣ㄣ
路 --console
灏嗛敊璇棩蹇楁秷鎭啓鍏stderr鍜stdout锛屽嵆浣挎寚瀹氫簡--log-error銆傚湪Windows涓紝濡傛灉浣跨敤璇ラ夐」锛mysqld涓嶅叧闂帶鍒跺彴绐楀彛銆
路 --character-sets-dir=path
瀛楃闆嗗畨瑁呯殑鐩綍銆傚弬瑙5.10.1鑺傦紝鈥滄暟鎹拰鎺掑簭鐢ㄥ瓧绗﹂泦鈥銆
路 --chroot=path
閫氳繃chroot()绯荤粺璋冪敤鍦ㄥ惎鍔ㄨ繃绋嬩腑灏mysqld鏈嶅姟鍣ㄦ斁鍏ヤ竴涓皝闂幆澧冧腑銆傝繖鏄帹鑽愮殑涓涓畨鍏ㄦ帾鏂姐傝娉ㄦ剰浣跨敤璇ラ夐」鍙互 闄愬埗LOAD DATA INFILE鍜SELECT ... INTO OUTFILE銆
路 --character-set-server=charset
浣跨敤charset浣滀负 榛樿鏈嶅姟鍣ㄥ瓧绗﹂泦銆傚弬瑙5.10.1鑺傦紝鈥滄暟鎹拰鎺掑簭鐢ㄥ瓧绗﹂泦鈥銆
路 --core-file
濡傛灉mysqld缁堟锛屽啓鍐呮牳鏂囦欢銆傚湪鏌愪簺绯荤粺涓紝浣犺繕蹇呴』涓mysqld_safe鎸囧畾--core-file-size 閫夐」銆傚弬瑙5.1.3鑺傦紝鈥渕ysqld_safe锛歁ySQL鏈嶅姟鍣ㄥ惎鍔ㄨ剼鏈銆傝娉ㄦ剰瀵逛簬涓浜涚郴缁燂紝渚嬪Solaris锛屽鏋滀綘浣跨敤--user閫夐」涓嶄細鑾峰緱鍐呮牳鏂囦欢銆
路 --collation-server=collation
浣跨敤collation浣滀负 榛樿鏈嶅姟鍣ㄦ牎瀵硅鍒欍傚弬瑙5.10.1鑺傦紝鈥滄暟鎹拰鎺掑簭鐢ㄥ瓧绗﹂泦鈥銆
路 --datadir=path, -h path
鏁版嵁鐩綍鐨勮矾寰勩
路 --debug[=debug_options], -# [debug_options]
濡傛灉MySQL閰嶇疆浜--with-debug锛屼綘鍙互浣跨敤璇ラ夐」鏉ヨ幏寰椾竴涓窡韪枃浠讹紝璺熻釜mysqld姝h繘琛岀殑鎿嶄綔銆debug_options瀛楃涓查氬父涓'd:t:o锛file_name'銆傚弬瑙E.1.2鑺傦紝鈥滃垱寤鸿窡韪枃浠垛銆
路 (DEPRECATED) --default-character-set=charset
浣跨敤char璁剧疆浣滀负 榛樿瀛楃闆嗐傜敱浜--character-set-server锛屽弽瀵逛娇鐢ㄨ閫夐」銆傚弬瑙5.10.1鑺傦紝鈥滄暟鎹拰鎺掑簭鐢ㄥ瓧绗﹂泦鈥銆
路 --default-collation=collation
浣跨敤collation 浣滀负榛樿鏍″瑙勫垯銆傜敱浜--collation-server锛屽弽瀵逛娇鐢ㄨ閫夐」銆傚弬瑙5.10.1鑺傦紝鈥滄暟鎹拰鎺掑簭鐢ㄥ瓧绗﹂泦鈥銆
路 --default-storage-engine=type
璇ラ夐」涓--default-table-type鐨勫悓涔夎瘝銆
路 --default-table-type=type
璁剧疆琛ㄧ殑榛樿绫诲瀷銆傚弬瑙绗15绔狅細瀛樺偍寮曟搸鍜岃〃绫诲瀷銆
路 --default-time-zone=type
璁剧疆榛樿鏈嶅姟鍣ㄦ椂鍖恒傝閫夐」璁剧疆鍏ㄥ眬time_zone绯荤粺鍙橀噺銆傚鏋滄湭缁欏嚭璇ラ夐」锛 榛樿鏃跺尯涓庣郴缁熸椂鍖虹浉鍚(鐢system_time_zone绯荤粺鍙橀噺鍊肩粰瀹)銆
路 --delay-key-write[= OFF | ON | ALL]
濡備綍浣跨敤DELAYED KEYS閫夐」銆傞敭鍐欏叆寤惰繜浼氶犳垚鍐嶆鍐MyISAM琛ㄦ椂閿紦鍐插尯涓嶈兘琚竻绌恒OFF绂佺敤寤惰繜鐨勯敭鍐欏叆銆ON鍚敤鐢DELAYED KEYS閫夐」鍒涘缓鐨勮〃鐨勫欢杩熺殑閿啓鍏ャALL寤惰繜鎵鏈MyISAM琛ㄧ殑閿啓鍏ャ傚弬瑙7.5.2鑺傦紝鈥滆皟鑺傛湇鍔″櫒鍙傛暟鈥銆傚弬瑙15.1.1鑺傦紝鈥淢yISAM鍚姩閫夐」鈥銆
娉閲婏細濡傛灉浣犲皢璇ュ彉閲忚缃负ALL锛屼綘涓嶅簲浠庡彟涓涓浣跨敤MyISAM琛ㄧ殑绋嬪簭涓娇鐢MyISAM琛(渚嬪浠庡彟涓涓MySQL鏈嶅姟鍣ㄦ垨鐢myisamchk)銆傝繖鏍锋搷浣滀細瀵艰嚧绱㈠紩鐮村潖銆
路 --des-key-file=file_name
浠庤鏂囦欢璇DES_ENCRYPT()鍜DES_DECRYPT()浣跨敤鐨 榛樿閿
路 --enable-named-pipe
鍚敤鍛藉悕绠¢亾鏀寔銆傝閫夐」鍙傜敤Windows NT銆2000銆XP鍜2003绯荤粺锛屽苟涓斿彧閫傜敤鏀寔鍛藉悕绠¢亾杩炴帴鐨mysqld-nt鍜mysqld-max-nt鏈嶅姟鍣ㄣ
路 --exit-info[=flags], -T [flags]
杩欐槸涓嶅悓鏍囧織鐨勪竴涓綅鎺╃爜锛屼綘鍙互鐢ㄦ潵璋冭瘯mysqld鏈嶅姟鍣銆備笉瑕佷娇鐢ㄨ閫夐」锛岄櫎闈炰綘纭垏鐭ラ亾瀹冨湪鍋氫粈涔堬紒
路 --external-locking
鍚敤绯荤粺閿佸畾銆傝娉ㄦ剰濡傛灉浣犲湪lockd涓嶈兘瀹屽叏宸ヤ綔鐨勭郴缁熶笂浣跨敤璇ラ夐」(渚嬪鍦Linux涓)锛mysqld瀹规槗姝婚攣銆傝閫夐」浠ュ墠鍙--enable-locking銆
娉閲婏細濡傛灉浣犲湪璁稿MySQL杩涚▼涓娇鐢ㄨ閫夐」鏉ユ洿鏂MyISAM琛紝浣犲繀椤荤‘淇濇弧瓒充笅杩版潯浠讹細
o 浣跨敤姝h鍙︿竴涓繘绋嬫洿鏂扮殑琛ㄧ殑鏌ヨ鐨勭紦瀛樹笉鍙娇鐢ㄣ
o 涓嶅簲鍦ㄥ叡浜〃涓娇鐢--delay-key-write=ALL鎴DELAY_KEY_WRITE=1銆
鏈绠鍗曠殑鏂规硶鏄粨鍚堜娇鐢--external-locking鍜--delay-key-write=OFF --query-cache-size=0銆
(榛樿涓嶈兘瀹炵幇锛屽洜涓哄湪璁稿璁剧疆涓紝缁撳悎浣跨敤涓婅堪閫夐」寰堟湁鐢級銆
路 --flush
鎵цSQL璇彞鍚庡悜纭洏涓婃竻绌烘洿鏀广備竴鑸儏鍐垫墽琛SQL璇彞鍚 MySQL鍚戠‖鐩樺啓鍏ユ墍鏈夋洿鏀癸紝璁╂搷浣滅郴缁熷鐞嗕笌纭洏鐨勫悓姝ャ傚弬瑙A.4.2鑺傦紝鈥滃鏋淢ySQL渚濈劧宕╂簝锛屽簲浣滀簺浠涔堚銆
路 --init-file=file
鍚姩鏃朵粠璇ユ枃浠惰SQL璇彞銆傛瘡涓鍙ュ繀椤诲湪鍚屼竴琛屼腑骞朵笖涓嶅簲鍖呮嫭娉ㄩ噴銆
路 --language=lang_name, -L lang_name
鐢ㄧ粰瀹氳瑷缁欏嚭瀹㈡埛绔敊璇秷鎭lang_name鍙互涓鸿瑷鍚嶆垨璇█鏂囦欢瀹夎鐩綍鐨勫叏璺緞鍚嶃傚弬瑙5.10.2鑺傦紝鈥滆缃敊璇秷鎭瑷鈥銆
路 --large-pages
涓浜涚‖浠/鎿嶄綔绯荤粺鏋舵瀯鏀寔澶т簬 榛樿鍊(閫氬父4 KB)鐨勫唴瀛橀〉銆傚疄闄呮敮鎸佸彇鍐充簬浣跨敤鐨勭‖浠跺拰OS銆傚ぇ閲忚闂唴瀛樼殑搴旂敤绋嬪簭閫氳繃浣跨敤杈冨ぇ鐨勯〉锛岄檷浣庝簡Translation Lookaside Buffer (TLB)鎹熷け锛屽彲浠ユ敼鍠勬ц兘銆
鐩墠锛MySQL鍙湪Linux涓敮鎸佸ぇ椤甸潰(鍦Linux涓绉颁綔HugeTLB)銆傛垜浠凡缁忚鍒掑皢璇ユ敮鎸佹墿灞曞埌FreeBSD銆Solaris鍜屽叾瀹冨彲鑳界殑骞冲彴銆
鍦Linux涓彲浠ヤ娇鐢ㄥぇ椤甸潰鍓嶏紝闇瑕侀厤缃HugeTLB鍐呭瓨姹犮傚弬鑰Linux鍐呮牳婧愮爜涓殑hugetlbpage.txt鏂囦欢銆
榛樿鎯呭喌涓嬭閫夐」琚鐢ㄣ
路 ---log[=file], -l [file]
鏃ュ織杩炴帴鍜屽鏂囦欢鐨勬煡璇€傚弬瑙5.11.2鑺傦紝鈥滈氱敤鏌ヨ鏃ュ織鈥銆傚鏋滀綘涓嶆寚瀹氭枃浠跺悕锛MySQL浣跨敤host_name.log浣滀负鏂囦欢鍚嶃
路 --log-bin=[file]
浜岃繘鍒舵棩蹇楁枃浠躲傚皢鏇存敼鏁版嵁鐨勬墍鏈夋煡璇㈣鍏ヨ鏂囦欢銆傜敤浜庡浠藉拰澶嶅埗銆傚弬瑙5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆傚缓璁寚瀹氫竴涓枃浠跺悕(鍘熷洜鍙傝A.8.1鑺傦紝鈥淢ySQL涓殑鎵撳紑浜嬪疁鈥)锛屽惁鍒MySQL浣跨敤host_name-bin浣滀负鏃ュ織鏂囦欢鍩烘湰鍚嶃
路 --log-bin-index[=file]
浜岃繘鍒舵棩蹇楁枃浠跺悕鐨勭储寮曟枃浠躲傚弬瑙5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆傚鏋滀綘涓嶆寚瀹氭枃浠跺悕锛屽苟涓斿鏋滀綘娌℃湁鍦--log-bin涓寚瀹氾紝MySQL浣跨敤host_name-bin.index浣滀负鏂囦欢鍚嶃
路 --log-bin-trust-routine-creators[={0|1}]
娌℃湁鍙傛暟鎴栧弬鏁颁负1,璇ラ夐」灏嗙郴缁熷彉閲log_bin_trust_routine_creators璁剧疆涓1銆備负鍙傛暟 0鏃讹紝璇ラ夐」灏嗙郴缁熷彉閲忚缃负0銆log_bin_trust_routine_creators褰卞搷MySQL濡備綍瀵逛繚瀛樼殑绋嬪簭鐨勫垱寤哄己鍔犻檺鍒躲傚弬瑙20.4鑺傦紝鈥滃瓨鍌ㄥ瓙绋嬪簭鍜岃Е鍙戠▼搴忕殑浜岃繘鍒舵棩蹇楀姛鑳解銆
路 --log-error[=file]
璇ユ枃浠剁殑鏃ュ織閿欒鍜屽惎鍔ㄦ秷鎭傚弬瑙5.11.1鑺傦紝鈥滈敊璇棩蹇椻銆傚鏋滀綘涓嶆寚瀹氭枃浠跺悕锛MySQL浣跨敤host_name.err浣滀负鏂囦欢鍚嶃傚鏋滄枃浠跺悕娌℃湁鎵╁睍鍚嶏紝鍒欏姞涓.err鎵╁睍鍚嶃
路 --log-isam[=file]
灏嗘墍鏈MyISAM鏇存敼璁板叆璇ユ枃浠(鍙湁璋冭瘯MyISAM鏃舵墠浣跨敤)銆
路 (DEPRECATED) --log-long-format
璁板綍婵娲荤殑鏇存柊鏃ュ織銆佷簩杩涘埗鏇存柊鏃ュ織銆佸拰鎱㈡煡璇㈡棩蹇楃殑澶ч噺淇℃伅銆備緥濡傦紝鎵鏈夋煡璇㈢殑鐢ㄦ埛鍚嶅拰鏃堕棿鎴冲皢璁板綍涓嬫潵銆備笉璧炴垚閫夌敤璇ラ夐」锛屽洜涓哄畠鐜板湪浠h〃 榛樿璁板綍琛屼负銆(鍙傝--log-short-format鎻忚堪锛銆--log-queries-not-using-indexes閫夐」閫傚悎灏嗘湭浣跨敤绱㈠紩鐨勬煡璇㈣褰曞埌鎱㈡煡璇㈡棩蹇椾腑銆
路 --log-queries-not-using-indexes
濡傛灉浣犵粨鍚--log-slow-queries浣跨敤璇ラ夐」锛屾湭浣跨敤绱㈠紩鐨勬煡璇篃琚褰曞埌鎱㈡煡璇㈡棩蹇椾腑銆傚弬瑙5.11.4鑺傦紝鈥滄參閫熸煡璇㈡棩蹇椻銆
路 --log-short-format
璁板綍婵娲荤殑鏇存柊鏃ュ織銆佷簩杩涘埗鏇存柊鏃ュ織銆佸拰鎱㈡煡璇㈡棩蹇楃殑灏戦噺淇℃伅銆備緥濡傦紝鐢ㄦ埛鍚嶅拰鏃堕棿鎴充笉璁板綍涓嬫潵銆
路 ---log-slow-admin-statements
灏嗘參绠$悊璇彞渚嬪OPTIMIZE TABLE銆ANALYZE TABLE鍜ALTER TABLE璁板叆鎱㈡煡璇㈡棩蹇椼
路 --log-slow-queries[=file]
灏嗘墍鏈夋墽琛屾椂闂磋秴杩long_query_time 绉掔殑鏌ヨ璁板叆璇ユ枃浠躲傚弬瑙5.11.4鑺傦紝鈥滄參閫熸煡璇㈡棩蹇椻銆傝缁嗕俊鎭弬瑙--log-long-format鍜--log-short-format閫夐」鎻忚堪銆
路 --log-warnings, -W
灏嗚鍛婁緥濡Aborted connection...鎵撳嵃鍒伴敊璇棩蹇椼傚缓璁惎鐢ㄨ閫夐」锛屼緥濡傦紝濡傛灉浣犱娇鐢ㄥ鍒 (浣犲彲浠ュ緱鍒板叧浜庢墍鍙戠敓浜嬫儏鐨勮缁嗕俊鎭紝渚嬪鍏充簬缃戠粶鏁呴殰鍜岄噸鏂拌繛鎺ョ殑娑堟伅)銆傞粯璁ゆ儏鍐典笅鍚敤璇ラ夐」锛涜鎯崇鐢ㄥ畠锛屼娇鐢--skip-log-warnings銆備腑鏂殑杩炴帴涓嶄細璁板叆閿欒鏃ュ織锛岄櫎闈炲煎ぇ浜1銆傚弬瑙A.2.10鑺傦紝鈥滈氫俊閿欒鍜屽け鏁堣繛鎺モ銆
路 --low-priority-updates
琛ㄤ慨鏀(INSERT, REPLACE, DELETE, UPDATE)姣旈夋嫨鐨勪紭鍏堢骇瑕佷綆銆備篃鍙互閫氳繃{INSERT | REPLACE | DELETE | UPDATE} LOW_PRIORITY ... 鏉ラ檷浣庢煇涓煡璇㈢殑浼樺厛绾ф潵瀹炵幇锛屾垨閫氳繃SET LOW_PRIORITY_UPDATES=1鏉ユ洿鏀逛竴涓嚎绋嬬殑浼樺厛绾с傚弬瑙7.3.2鑺傦紝鈥滆〃閿佸畾浜嬪疁鈥銆
路 --memlock
灏mysqld 杩涚▼閿佸畾鍦ㄥ唴瀛樹腑銆傚湪鏀寔mlockall()绯荤粺璋冪敤鐨勭郴缁熶笂鏈夋晥锛屼緥濡Solaris銆傚鏋滄搷浣滅郴缁熶娇mysqld鍦ㄧ‖鐩樹笂浜ゆ崲鏃跺嚭鐜伴棶棰橈紝鍙互涓轰綘鎻愪緵甯姪銆傝娉ㄦ剰浣跨敤璇ラ夐」鏃堕渶瑕佷互root杩愯鏈嶅姟鍣紝浣嗕粠瀹夊叏鑰冭檻骞朵笉鏄竴涓ソ娉ㄦ剰銆
路 --myisam-recover [=option[,option...]]]
灏嗗瓨鍌ㄥ紩鎿MyISAM璁剧疆涓烘仮澶嶆ā寮忋傝閫夐」鍊兼槸DEFAULT銆BACKUP銆FORCE鎴QUICK鍊肩殑浠讳綍缁勫悎銆傚鏋滀綘鎸囧畾澶氫釜鍊硷紝鐢ㄩ楀彿闂撮殧寮銆備綘杩樺彲浠ヤ娇鐢""鍊兼潵绂佺敤璇ラ夐」銆備娇鐢ㄥ鏋滆閫夐」锛屽綋mysqld鎵撳紑MyISAM琛ㄦ椂锛屾鏌ユ槸鍚﹁〃鏍囪涓哄穿婧冩垨娌℃湁姝g‘鍏抽棴銆(鍙湁鐢--skip-external-lockingare杩愯鏃讹紝鏈鍚庣殑閫夐」鎵嶅伐浣滐級銆 濡傛灉鏄繖绉嶆儏鍐碉紝mysqld鍒欐鏌 琛ㄣ傚鏋滆〃琚牬鍧忥紝mysqld璇曞浘缁存姢瀹冦
涓嬮潰鐨勯夐」褰卞搷缁存姢宸ヤ綔锛
閫夐」 |
鎻忚堪 |
DEFAULT |
涓庢病鏈変娇鐢--myisam-recover閫夐」鐩稿悓銆 |
BACKUP |
濡傛灉鍦ㄦ仮澶嶈繃绋嬩腑锛屾暟鎹枃浠惰鏇存敼浜嗭紝灏tbl_name.MYD鏂囦欢澶囦唤涓tbl_name-datetime.BAK銆 |
FORCE |
鍗充娇.MYD鏂囦欢灏嗕涪鎺夊涓涔熻繘琛屾仮澶嶃 |
QUICK |
濡傛灉娌℃湁鍒犻櫎鍧楋紝涓嶈妫鏌ヨ〃涓殑琛屻 |
鍦ㄨ〃鑷姩淇鍓嶏紝MySQL閿欒鏃ュ織娣诲姞涓鏉℃敞瑙c傚鏋滀綘涓嶆兂鐢ㄦ埛骞叉秹骞叉秹澶у鏁伴棶棰橈紝浣犲簲浣跨敤BACKUP,FORCE閫夐」銆傝閫夐」寮哄埗缁存姢琛紝鍗充娇涓浜涜灏嗕細琚垹闄や篃涓嶄緥澶栵紝浣嗗畠淇濇寔鏃х殑鏁版嵁鏂囦欢鍋氫负澶囦唤锛屼互渚夸綘鍙互鍦ㄥ悗鏉ヨ繘琛屾鏌ャ
路 --ndb-connectstring=connect_string
褰撲娇鐢NDB瀛樺偍寮曟搸鏃讹紝鍙互鎸囧嚭閫氳繃璁剧疆杩炴帴瀛楃涓查夐」鏉ュ垎鍙戠兢闆嗛厤缃殑绠$悊鏈嶅姟鍣ㄣ傜浉鍏宠娉曞弬瑙17.4.4.2鑺傦紝鈥淢ySQL绨囪繛鎺ュ瓧绗︿覆鈥銆
路 --ndbcluster
濡傛灉浜岃繘鍒舵敮鎸NDB CLUSTER瀛樺偍寮曟搸锛屼娇鐢ㄨ閫夐」鍙互浠f浛绂佺敤MySQL Cluster鏀寔鐨 榛樿璁剧疆銆傚弬瑙绗17绔狅細MySQL绨銆
路 --old-passwords
寮哄埗鏈嶅姟鍣ㄤ负鏂板瘑鐮佺敓鎴愮煭(4.1鍓)瀵嗙爜鍝堝笇銆傚鏋滄湇鍔″櫒蹇呴』鏀寔鏃у鎴风绋嬪簭锛屼负淇濊瘉鍏煎鎬ц繖寰堟湁鐢ㄣ傚弬瑙5.7.9鑺傦紝鈥淢ySQL 4.1涓殑瀵嗙爜鍝堝笇澶勭悊鈥銆
路 --one-thread
鍙娇鐢ㄤ竴涓嚎绋(鐢ㄤ簬鍦Linux涓皟璇)銆傚彧鏈夋湇鍔″櫒鍚敤浜嗚皟璇曪紝璇ラ夐」鎵嶅彲鐢ㄣ傚弬瑙E.1鑺傦紝鈥滆皟璇昅ySQL鏈嶅姟鍣ㄢ銆
路 --open-files-limit=count
鐢ㄦ潵鏇存敼mysqld鏂囦欢鎻忚堪绗︾殑鏁伴噺銆傚鏋滄病鏈夎缃垨璁剧疆涓0锛屽垯mysqld閫氳繃setrlimit()浣跨敤璇ュ兼潵淇濆瓨鏂囦欢鎻忚堪绗︺傚鏋滆鍊间负0锛屽垯mysqld 淇濆瓨max_connections*5鎴max_connections + table_cache*2(鍙栬緝澶ц)涓枃浠躲傚鏋mysqld缁欏嚭浣犻敊璇"鎵撳紑鐨勬枃浠跺お澶氥"锛屼綘搴旇瘯璇曞鍔犺鍊笺
路 --pid-file=path
mysqld_safe浣跨敤鐨勮繘绋ID鏂囦欢鐨勮矾寰勩
路 --port=port_num, -P port_num
甯у惉TCP/IP杩炴帴鏃朵娇鐢ㄧ殑绔彛鍙枫
路 --safe-mode
璺宠繃涓浜涗紭鍖栭樁娈点
路 (DEPRECATED) --safe-show-database
路 --safe-user-create
鍚敤鍚庡鏋滅敤鎴锋病鏈mysql.user琛ㄦ垨琛ㄤ腑鍒楃殑INSERT鏉冮檺锛屽垯鐢ㄦ埛涓嶈兘鐢GRANT璇彞鍒涘缓鏂扮敤鎴枫
路 --secure-auth
涓嶅厑璁镐娇鐢ㄦ棫(4.1涔嬪墠)瀵嗙爜鐨勮处鎴疯繘琛岄壌瀹氥
路 --shared-memory
鍚敤鏈湴瀹㈡埛绔殑鍏变韩鍐呭瓨杩炴帴銆傝閫夐」鍙敤浜Windows銆
路 --shared-memory-base-name=name
鍏变韩鍐呭瓨杩炴帴鍚嶃傝閫夐」鍙敤浜Windows銆
路 --skip-bdb
绂佺敤BDB瀛樺偍寮曟搸銆傝繖鏍峰彲浠ヨ妭鐪佸唴瀛橈紝骞跺彲鑳藉姞閫熸煇浜涙搷浣溿傚鏋滀綘闇瑕BDB琛ㄥ垯涓嶈浣跨敤璇ラ夐」銆
路 --skip-concurrent-insert
鍏抽棴鍦ㄥ悓涓鏃堕棿鍦MyISAM琛ㄤ腑閫夋嫨鍜屾彃鍏ョ殑鑳藉姏銆(鍙湁浣犲彂鐜扮己闄锋椂鎵嶄娇鐢ㄨ閫夐」锛銆
路 --skip-external-locking
涓嶈浣跨敤绯荤粺閿佸畾銆傝鎯充娇鐢myisamchk锛屼綘蹇呴』鍏抽棴鏈嶅姟鍣ㄣ(鍙傝1.4.3鑺傦紝鈥淢ySQL绋冲畾鎬р锛銆 瑕侀伩鍏嶈闇姹傦紝浣跨敤MySQL Monitor涓殑CHECK TABLE鍜REPAIR TABLE鏉ユ鏌ュ苟缁存姢MyISAM琛ㄣ
路 --skip-grant-tables
璇ラ夐」浣挎湇鍔″櫒涓嶄娇鐢ㄦ潈闄愮郴缁熴傝鏉冮檺鍏佽璁块棶鏈嶅姟鍣ㄧ殑鐢ㄦ埛涓嶅彈闄愬埗鍦拌闂鎵鏈鏁版嵁搴銆備綘鍙互浠庣郴缁熷澹冲懡浠よ鎵цmysqladmin flush-privileges鎴mysqladmin reload鍛戒护锛屾垨鎵цMySQL FLUSH PRIVILEGES璇彞璁╄繍琛岀殑鏈嶅姟鍣ㄩ噸鏂板紑濮嬩娇鐢 鎺堟潈琛ㄣ
路 --skip-host-cache
涓轰簡鏇村揩鍦板湪鍚嶇О-IP涔嬮棿杩涜瑙f瀽锛屼笉瑕佷娇鐢ㄥ唴閮ㄤ富鏈哄悕缂撳瓨銆傜浉鍙嶏紝姣忔瀹㈡埛绔繛鎺ユ椂鏌ヨDNS鏈嶅姟鍣ㄣ傚弬瑙7.5.6鑺傦紝鈥淢ySQL濡備綍浣跨敤DNS鈥銆
路 --skip-innodb
绂佺敤InnoDB瀛樺偍寮曟搸銆傝繖鏍峰彲浠ヨ妭鐪佸唴瀛橈紝骞跺彲鑳藉姞閫熸煇浜涙搷浣溿傚鏋滀綘闇瑕BDB琛ㄥ垯涓嶈浣跨敤璇ラ夐」銆
路 --skip-name-resolve
涓嶈瑙f瀽姝f鏌ュ鎴风杩炴帴鐨勪富鏈哄悕銆傚彧浣跨敤IP鍙枫傚鏋滀綘浣跨敤璇ラ」锛 鎺堟潈琛ㄤ腑鐨勬墍鏈Host鍒楀煎繀椤讳负IP鍙锋垨localhost銆傚弬瑙7.5.6鑺傦紝鈥淢ySQL濡備綍浣跨敤DNS鈥銆
路 --skip-ndbcluster
绂佺敤NDB CLUSTER瀛樺偍寮曟搸銆傝繖鏄敮鎸NDB CLUSTER瀛樺偍寮曟搸鐨勪簩杩涘埗鐨勯粯璁よ缃紝璇存槑鍙湁鐢--ndbcluster閫夐」鏄惧紡瑕嗙洊--skip-ndbcluster閫夐」鏃讹紝绯荤粺鎵嶄负璇ュ瓨鍌ㄥ紩鎿庡垎閰嶅唴瀛樺拰鍏跺畠璧勬簮銆備娇鐢ㄧず渚嬪弬瑙17.4.3鑺傦紝鈥淢ySQL绨囩殑蹇熸祴璇曡缃銆
路 --skip-networking
涓嶅抚鍚TCP/IP杩炴帴銆傚繀椤婚氳繃鍛藉悕绠¢亾鎴栧叡浜唴瀛(鍦Windows涓)鎴Unix濂楁帴瀛楁枃浠(鍦Unix涓)瀹屾垚mysqld鐨勭浉浜掓搷浣溿傚浜庡彧鍏佽鏈湴瀹㈡埛绔殑绯荤粺锛屽ぇ鍔涙帹鑽愯閫夐」銆傚弬瑙7.5.6鑺傦紝鈥淢ySQL濡備綍浣跨敤DNS鈥銆
路 --standalone
鍙傚悎鍩轰簬Windows-NT鐨勭郴缁燂紱鎸囧MySQL鏈嶅姟鍣ㄤ笉鍋氫负鏈嶅姟鏉ヨ繍琛屻
路 --symbolic-links, --skip-symbolic-links
鍚敤鎴栫鐢ㄧ鍙烽摼鎺ユ敮鎸併傚湪Windows鍜Unix涓紝璇ラ夐」鐨勪綔鐢ㄦ槸涓嶅悓鐨勶細
o 鍦Windows涓紝鍚敤绗﹀彿閾炬帴锛屼綘鍙互閫氳繃鍒涘缓鍖呭惈瀹為檯鐩綍璺緞鐨directory.sym鏂囦欢鏉ュ缓绔嬫暟鎹簱鐩綍鐨勭鍙烽摼鎺ャ傚弬瑙7.6.1.3鑺傦紝鈥滃湪Windows骞冲彴涓婁娇鐢ㄥ叧浜庢暟鎹簱鐨勭鍙烽摼鎺モ銆
鍦Unix涓紝鍚敤绗﹀彿閾炬帴琛ㄧず浣犲彲浠ョ敤CREATE TABLE璇彞鐨INDEX DIRECTORY鎴DATA DIRECTORY閫夐」灏MyISAM绱㈠紩鏂囦欢鎴栨暟鎹枃浠堕摼鎺ュ埌鍙︿竴涓洰褰曘傚鏋滀綘鍒犻櫎鎴栭噸鏂板懡鍚嶈〃锛岀鍙烽摼鎺ユ墍鎸囩殑鏂囦欢涔熻鍒犻櫎鎴栭噸鏂板懡鍚嶃傚弬瑙13.1.5鑺傦紝鈥淐REATE TABLE璇硶鈥銆
路 --skip-safemalloc
濡傛灉MySQL閰嶇疆浜--with-debug=full锛屾墍鏈MySQL绋嬪簭鍦ㄥ唴瀛樺垎閰嶅拰閲婃斁鏃舵鏌ュ唴瀛樻槸鍚︽孩鍑恒傛鏌ュ緢鎱紝鍥犳濡傛灉浣犱笉闇瑕佷綘鍙互鐢--skip-safemalloc閫夐」鏉ラ伩鍏嶃
路 --skip-show-database
浣跨敤璇ラ夐」锛屽彧鍏佽鍏锋湁SHOW DATABASES鏉冮檺鐨勭敤鎴锋墽琛SHOW DATABASES璇彞锛岃璇彞鏄剧ず鎵鏈夋暟鎹簱鍚嶃備笉浣跨敤璇ラ夐」锛屽厑璁告墍鏈夌敤鎴锋墽琛SHOW DATABASES锛屼絾鍙悜鍏锋湁SHOW DATABASES鏉冮檺鎴栭儴鍒嗘暟鎹簱鏉冮檺鐨勭敤鎴锋樉绀烘瘡涓暟鎹簱鍚嶃傝娉ㄦ剰鍏ㄥ眬鏉冮檺涓烘暟鎹簱鐨勪竴绉嶆潈闄愩
路 --skip-stack-trace
涓嶈窡韪啓鍫嗘爤銆傚綋璋冭瘯杩愯mysqld鏃惰閫夐」鏈夌敤銆傚湪涓浜涚郴缁熶腑锛屼綘杩樺繀椤讳娇鐢ㄨ閫夐」鏉ヨ幏寰楀唴鏍告枃浠躲傚弬瑙E.1鑺傦紝鈥滆皟璇昅ySQL鏈嶅姟鍣ㄢ銆
路 --skip-thread-priority
鍦ㄥ揩閫熷搷搴斾腑绂佺敤绾跨▼浼樺厛绾с
路 --socket=path
鍦Unix涓紝璇ラ夐」鎸囧畾鐢ㄤ簬鏈湴杩炴帴鐨Unix濂楁帴瀛楁枃浠躲 榛樿鍊兼槸/tmp/mysql.sock銆傚湪Windows涓紝璇ラ夐」鎸囧畾鏈湴杩炴帴鎵浣跨敤鐨勭閬撳悕銆 榛樿鍊兼槸MySQL銆
路 --sql-mode=value[,value[,value...]]
灏MySQL璁剧疆涓SQL妯″紡銆傚弬瑙5.3.2鑺傦紝鈥淪QL鏈嶅姟鍣ㄦā寮忊銆
路 --temp-pool
璇ラ夐」浣挎湇鍔″櫒鍒涘缓鐨勫ぇ澶氭暟涓存椂鏂囦欢浣跨敤涓绯诲垪鏂囦欢鍚嶏紝鑰屼笉鏄瘡涓柊鏂囦欢浣跨敤鍞竴鐨勬枃浠跺悕銆傝繖鏍疯В鍐充簡鍦Linux鍐呮牳涓敤 涓嶅悓鐨勫悕鍒涘缓璁稿鏂版枃浠剁殑闂銆傚湪浠ュ墠锛Linux浼间箮鈥滄硠婕忊濆唴瀛橈紝鍥犱负瀹冭鐩存帴鍒嗛厤鍒directory entry缂撳瓨鑰屼笉鏄‖鐩樼紦瀛樸
路 --transaction-isolation=level
璁剧疆榛樿浜嬪姟闅旂绾у埆锛屽彲浠READ-UNCOMMITTED銆READ-COMMITTEE銆REPEATABLE-READ鎴SERIALIZABLE銆傚弬瑙13.4.6鑺傦紝鈥淪ET TRANSACTION璇硶鈥銆
路 --tmpdir=path, -t path
鍒涘缓涓存椂鏂囦欢鐨勭洰褰曡矾寰勩傞粯璁/tmp鐩綍鍦ㄥお灏忎笉鑳藉绾充复鏃惰〃鐨勫垎鍖烘椂璇ラ夐」寰堟湁鐢ㄣ傝閫夐」鎺ュ彈round-robin妯″紡鐨勫嚑涓矾寰勩傚湪Unix涓矾寰勫簲鐢ㄥ啋鍙(鈥:鈥) 闂撮殧寮锛屽湪Windows銆NetWare鍜OS/2涓敤鍒嗗彿(鈥锛鈥) 闂撮殧寮銆傚鏋MySQL鏈嶅姟鍣ㄤ负澶嶅埗浠庢満锛屼綘涓嶅簲璁--tmpdir鎸囧悜鍩轰簬鍐呭瓨鐨勬枃浠剁郴缁熶腑鐨勭洰褰曟垨鏈嶅姟鍣ㄤ富鏈洪噸鍚椂浼氭竻闄ょ殑鐩綍銆傚鍒朵粠鏈洪渶瑕佷复鏃舵枃浠讹紝鏈哄櫒閲嶅惎鏃跺彲浠ュ鍒朵复鏃惰〃鎴栨墽琛LOAD DATA INFILE鎿嶄綔銆傚鏋滄湇鍔″櫒閲嶅惎鏃朵复鏃舵枃浠剁洰褰曚腑鐨勬枃浠朵涪澶憋紝澶嶅埗澶辫触銆
路 --user={user_name | user_id}, -u {user_name | user_id}
鐢user_name鎴栨暟瀛楃敤鎴ID user_id杩愯mysqld鏈嶅姟鍣銆(鈥鐢ㄦ埛鈥濇寚绯荤粺鐧诲綍璐︽埛锛岃屼笉鏄 鎺堟潈琛ㄤ腑鎵鍒楃殑MySQL鐢ㄦ埛锛銆
鐢root鍚姩mysqld鏃寮哄埗浣跨敤璇ラ夐」銆傛湇鍔″櫒鍦ㄥ惎鍔ㄥ簭鍒椾腑鏇存敼鐢ㄦ埛ID锛岃瀹冨仛涓哄叿浣撶敤鎴疯屼笉鏄root杩愯銆傚弬瑙5.6.1鑺傦紝鈥滈氱敤瀹夊叏鎸囧崡鈥銆
瑕侀伩鍏嶇敤鎴峰湪my.cnf鏂囦欢涓坊鍔--user=root閫夐」(浣挎湇鍔″櫒鐢root杩愯)鏃跺彲鑳藉嚭鐜扮殑瀹夊叏婕忔礊锛mysqld鍙娇鐢ㄦ寚瀹氱殑绗1涓--user閫夐」锛屽鏋滄湁澶氫釜--user閫夐」鍒欎細鍑虹幇璀﹀憡銆傚湪鍛戒护琛岄夐」鍓嶅鐞/etc/my.cnf鍜$MYSQL_HOME/my.cnf涓殑閫夐」锛屽洜姝ゅ缓璁綘鍦/etc/my.cnf涓斁涓涓--user閫夐」锛屽苟鎸囧畾root涔嬪鐨勫叾瀹冨笺傚湪鍏跺畠--user閫夐」鍓嶅厛鎵惧埌/etc/my.cnf涓殑閫夐」锛岀‘淇濇湇鍔″櫒鐢ㄥ叾瀹冪敤鎴疯繍琛岋紝濡傛灉鎵惧埌鍏跺畠--user閫夐」鍒欎細鍑虹幇璀﹀憡銆
路 --version, -V
鏄剧ず鐗堟湰淇℃伅骞堕鍑恒
浣犲彲浠ヤ娇鐢--var_name=value褰㈠紡鐨勯夐」涓烘湇鍔″櫒绯荤粺鍙橀噺銆備緥濡傦紝--key_buffer_size=32M灏嗗彉閲key_buffer_size璁句负32MB銆
璇锋敞鎰忚缃彉閲忔椂锛MySQL鍙互鑷姩灏嗗畠绾犳鍒版煇涓粰瀹氳寖鍥村唴锛屾垨濡傛灉鍙厑璁告煇涓硷紝鍒欏皢璁剧疆鍊艰皟鑺傚埌鏈鎺ヨ繎鍏佽鐨勫笺
杩樺彲浠ラ氳繃--set-variable=var_name=value鎴-O var_name=value璇硶鏉ヨ缃彉閲忋備絾鏄紝鐜板湪涓嶈禐鎴愪娇鐢ㄨ璇硶銆
5.3.3鑺傦紝鈥滄湇鍔″櫒绯荤粺鍙橀噺鈥瀹屽叏鎻忚堪浜嗗叏閮ㄧ郴缁熷彉閲忋傝皟鑺傛湇鍔″櫒鍙傛暟閮ㄥ垎鍖呮嫭濡備綍瀵逛粬浠繘琛屼紭鍖栥傚弬瑙7.5.2鑺傦紝鈥滆皟鑺傛湇鍔″櫒鍙傛暟鈥銆
浣犲彲浠ョ敤SET璇彞鏇存敼澶у鏁版湇鍔″櫒绯荤粺鍙橀噺鐨勫笺傚弬瑙13.5.3鑺傦紝鈥淪ET璇硶鈥銆
濡傛灉浣犳兂鐢SET 闄愬埗鍚姩椤瑰彲璁剧殑鏈澶у硷紝浣犲彲浠ヤ娇鐢--maximum-var_name鍛戒护琛岄夐」鏉ュ畾涔夈
MySQL鏈嶅姟鍣ㄥ彲浠ヤ互涓嶅悓鐨SQL妯″紡鏉ユ搷浣滐紝骞朵笖鍙互涓轰笉鍚屽鎴风搴旂敤涓嶅悓妯″紡銆傝繖鏍锋瘡涓簲鐢ㄧ▼搴忓彲浠ユ牴鎹嚜宸辩殑闇姹傛潵瀹氬埗鏈嶅姟鍣ㄧ殑鎿嶄綔妯″紡銆
妯″紡瀹氫箟MySQL搴旀敮鎸佸摢浜SQL璇硶锛屼互鍙婂簲鎵ц鍝鏁版嵁楠岃瘉妫鏌ャ傝繖鏍峰彲浠ユ洿瀹规槗鍦板湪涓嶅悓鐨勭幆澧冧腑浣跨敤MySQL锛屽苟缁撳悎鍏跺畠鏁版嵁搴撴湇鍔″櫒浣跨敤MySQL銆
浣犲彲浠ョ敤--sql-mode="modes"閫夐」鍚姩mysqld鏉璁剧疆榛樿SQL妯″紡銆傚鏋滀綘鎯宠閲嶈锛岃鍊艰繕鍙互涓虹┖(--sql-mode ="")銆
浣犺繕鍙互鍦ㄥ惎鍔ㄥ悗鐢SET [SESSION|GLOBAL] sql_mode='modes'璇彞璁剧疆sql_mode鍙橀噺鏉ユ洿鏀SQL妯″紡銆傝缃 GLOBAL鍙橀噺鏃堕渶瑕佹嫢鏈SUPER鏉冮檺锛屽苟涓斾細褰卞搷浠庨偅鏃惰捣杩炴帴鐨勬墍鏈夊鎴风鐨勬搷浣溿傝缃SESSION鍙橀噺鍙奖鍝嶅綋鍓嶇殑瀹㈡埛绔備换浣曞鎴风鍙互闅忔椂鏇存敼鑷繁鐨勪細璇 sql_mode鍊笺
Modesis鏄敤閫楀彿(鈥锛鈥)闂撮殧寮鐨勪竴绯诲垪涓嶅悓鐨勬ā寮忋備綘鍙互鐢SELECT @@sql_mode璇彞鏌ヨ褰撳墠鐨勬ā寮忋傞粯璁ゅ兼槸绌(娌℃湁璁剧疆浠讳綍妯″紡)銆
涓昏閲嶈sql_mode鍊间负锛
路 ANSI
鏇存敼璇硶鍜岃涓猴紝浣垮叾鏇寸鍚堟爣鍑SQL銆
路 STRICT_TRANS_TABLES
濡傛灉涓嶈兘灏嗙粰瀹氱殑鍊兼彃鍏ュ埌浜嬪姟琛ㄤ腑锛屽垯鏀惧純璇ヨ鍙ャ傚浜庨潪浜嬪姟琛紝濡傛灉鍊煎嚭鐜板湪鍗曡璇彞鎴栧琛岃鍙ョ殑绗1琛岋紝鍒欐斁寮冭璇彞銆傛湰鑺傚悗闈㈢粰鍑轰簡鏇磋缁嗙殑鎻忚堪銆
路 TRADITIONAL
Make MySQL鐨勮涓鸿薄鈥浼犵粺鈥SQL鏁版嵁搴撶郴缁熴傝妯″紡鐨勭畝鍗曟弿杩版槸褰撳湪鍒椾腑鎻掑叆涓嶆纭殑鍊兼椂鈥滅粰鍑閿欒鑰屼笉鏄鍛鈥濄娉閲婏細涓鏃﹀彂鐜伴敊璇珛鍗虫斁寮INSERT/UPDATE銆傚鏋滀綘浣跨敤闈炰簨鍔″瓨鍌ㄥ紩鎿庯紝杩欑鏂瑰紡涓嶆槸浣犳兂瑕佺殑锛屽洜涓哄嚭鐜伴敊璇墠杩涜鐨勬暟鎹洿鏀逛笉浼氣滄粴鍔ㄢ濓紝缁撴灉鏄洿鏂扳滃彧杩涜浜嗕竴閮ㄥ垎鈥濄
鏈墜鍐屾寚鈥涓ユ牸妯″紡鈥濓紝琛ㄧず鑷冲皯STRICT _TRANS_TABLES鎴STRICT _ALL_TABLES琚惎鐢ㄧ殑妯″紡銆
涓嬮潰鎻忚堪浜嗘敮鎸佺殑鎵鏈夋ā寮忥細
路 ALLOW_INVALID_DATES
鍦ㄤ弗鏍兼ā寮忎笅涓嶈妫鏌ュ叏閮ㄦ棩鏈熴傚彧妫鏌1鍒12涔嬮棿鐨勬湀浠藉拰1鍒31涔嬮棿鐨勬棩銆傝繖鍦Web搴旂敤绋嬪簭涓紝褰撲綘浠庝笁涓笉鍚岀殑瀛楁鑾峰彇骞淬佹湀銆佹棩锛屽苟涓旀兂瑕佺‘鍒囦繚瀛樼敤鎴锋彃鍏ョ殑鍐呭(涓嶈繘琛屾棩鏈熼獙璇)鏃跺緢閲嶈銆傝妯″紡閫傜敤浜DATE鍜DATETIME鍒椼備笉閫傚悎TIMESTAMP鍒楋紝TIMESTAMP鍒楅渶瑕侀獙璇佹棩鏈熴
鍚敤涓ユ牸妯″紡鍚庯紝鏈嶅姟鍣ㄩ渶瑕佸悎娉曠殑鏈堝拰鏃ワ紝涓嶄粎浠呮槸鍒嗗埆鍦1鍒12鍜1鍒31鑼冨洿鍐呫備緥濡傦紝绂佺敤涓ユ牸妯″紡鏃'2004-04-31'鏄悎娉曠殑锛屼絾鍚敤涓ユ牸妯″紡鍚庢槸闈炴硶鐨勩傝鎯冲湪涓ユ牸妯″紡鍏佽閬帺鍥哄畾鏃ユ湡锛岃繕搴斿惎鐢ALLOW_INVALID_DATES銆
路 ANSI_QUOTES
灏嗏"鈥欒涓鸿瘑鍒寮曞彿(鈥`鈥欏紩鍙峰瓧绗)锛屼笉瑕佽涓哄瓧绗︿覆鐨勫紩鍙峰瓧绗︺傚湪ANSI妯″紡锛屼綘鍙互浠嶇劧浣跨敤鈥`鈥欐潵寮曠敤璇嗗埆绗︺傚惎鐢ANSI_QUOTES鍚庯紝浣犱笉鑳界敤鍙屽紩鍙锋潵寮曠敤瀛楃涓诧紝鍥犱负瀹冭瑙i噴涓鸿瘑鍒銆
路 ERROR_FOR_DIVISION_BY_ZERO
鍦ㄤ弗鏍兼ā寮忥紝鍦INSERT鎴UPDATE杩囩▼涓紝濡傛灉琚浂闄(鎴MOD(X锛0))锛屽垯浜х敓閿欒(鍚﹀垯涓鸿鍛)銆傚鏋滄湭缁欏嚭璇ユā寮忥紝琚浂闄ゆ椂MySQL杩斿洖NULL銆傚鏋滅敤鍒INSERT IGNORE鎴UPDATE IGNORE涓紝MySQL鐢熸垚琚浂闄よ鍛婏紝浣嗘搷浣滅粨鏋滀负NULL銆
路 HIGH_NOT_PRECEDENCE
NOT鎿嶄綔绗︾殑浼樺厛椤哄簭鏄〃杈惧紡渚嬪NOT a BETWEEN b AND c琚В閲婁负NOT (a BETWEEN b AND c)銆傚湪涓浜涙棫鐗堟湰MySQL涓紝 琛ㄨ揪寮忚瑙i噴涓(NOT a) BETWEEN b AND c銆傚惎鐢HIGH_NOT_PRECEDENCESQL妯″紡锛屽彲浠ヨ幏寰椾互鍓嶇殑鏇撮珮浼樺厛绾х殑缁撴灉銆
mysql> SET sql_mode = '';
mysql> SELECT NOT 1 BETWEEN -5 AND 5;
-> 0
mysql> SET sql_mode = 'broken_not';
mysql> SELECT NOT 1 BETWEEN -5 AND 5;
-> 1
路 IGNORE_SPACE
鍏佽鍑芥暟鍚嶅拰鈥(鈥欎箣闂存湁绌烘牸銆傚己鍒跺皢鎵鏈夊嚱鏁板悕瑙嗕负淇濆瓨鐨勫瓧銆傜粨鏋滄槸锛屽鏋滀綘鎯宠璁块棶淇濆瓨涓哄瓧鐨勬暟鎹簱銆佽〃鎴栧垪鍚嶏紝浣犲繀椤诲紩鐢ㄥ畠銆備緥濡傦紝鍥犱负鏈USER()鍑芥暟锛mysql鏁版嵁搴撲腑鐨user琛ㄥ悕鍜岃琛ㄥ唴鐨User鍒楄淇濆瓨涓嬫潵锛屽洜姝や綘蹇呴』寮曠敤瀹冧滑锛
SELECT "User" FROM mysql."user";
路 NO_AUTO_CREATE_USER
闃叉GRANT鑷姩鍒涘缓鏂扮敤鎴凤紝闄ら潪杩樻寚瀹氫簡瀵嗙爜銆
路 NO_AUTO_VALUE_ON_ZERO
NO_AUTO_VALUE_ON_ZERO褰卞搷AUTO_INCREMENT鍒楃殑澶勭悊銆備竴鑸儏鍐碉紝浣犲彲浠ュ悜璇ュ垪鎻掑叆NULL鎴0鐢熸垚涓嬩竴涓簭鍒楀彿銆NO_AUTO_VALUE_ON_ZERO绂佺敤0锛屽洜姝ゅ彧鏈NULL鍙互鐢熸垚涓嬩竴涓簭鍒楀彿銆
濡傛灉灏0淇濆瓨鍒拌〃鐨AUTO_INCREMENT鍒楋紝璇ユā寮忎細寰堟湁鐢ㄣ(涓嶆帹鑽愰噰鐢ㄨ鎯緥)銆備緥濡傦紝濡傛灉浣犵敤mysqldump杞偍琛ㄥ苟閲嶈浇锛MySQL閬囧埌0鍊间竴鑸細鐢熸垚鏂扮殑搴忓垪鍙凤紝鐢熸垚鐨勮〃鐨勫唴瀹逛笌杞偍鐨勮〃涓嶅悓銆傞噸杞借浆鍌ㄦ枃浠跺墠鍚敤NO_AUTO_VALUE_ON_ZERO鍙互瑙e喅璇ラ棶棰樸mysqldump鍦ㄨ緭鍑轰腑鑷姩鍖呮嫭鍚敤NO_AUTO_VALUE_ON_ZERO鐨勮鍙ャ
路 NO_BACKSLASH_ESCAPES
绂佺敤鍙嶆枩绾垮瓧绗(鈥\鈥)鍋氫负瀛楃涓插唴鐨勯鍑哄瓧绗︺傚惎鐢ㄨ妯″紡锛屽弽鏂滅嚎鍒欐垚涓烘櫘閫氬瓧绗︺
路 NO_DIR_IN_CREATE
鍒涘缓琛ㄦ椂锛屽拷瑙嗘墍鏈INDEX DIRECTORY鍜DATA DIRECTORY鎸囦护銆傝閫夐」瀵逛粠澶嶅埗鏈嶅姟鍣ㄦ湁鐢ㄣ
路 NO_ENGINE_SUBSTITUTION
濡傛灉闇瑕佺殑瀛樺偍寮曟搸琚鐢ㄦ垨鏈紪璇戯紝鍙互闃叉鑷姩鏇挎崲瀛樺偍寮曟搸銆
路 NO_FIELD_OPTIONS
涓嶈鍦SHOW CREATE TABLE鐨勮緭鍑轰腑鎵撳嵃MySQL涓撶敤鍒楅夐」銆傝妯″紡鍦ㄥ彲绉绘妯″紡锛portability mode锛変笅鐢ㄤ簬mysqldump銆
路 NO_KEY_OPTIONS
涓嶈鍦SHOW CREATE TABLE鐨勮緭鍑轰腑鎵撳嵃MySQL涓撶敤绱㈠紩閫夐」銆傝妯″紡鍦ㄥ彲绉绘妯″紡锛portability mode锛変笅鐢ㄤ簬mysqldump銆
路 NO_TABLE_OPTIONS
涓嶈鍦SHOW CREATE TABLE鐨勮緭鍑轰腑鎵撳嵃MySQL涓撶敤琛ㄩ夐」锛堜緥濡ENGINE锛夈傝妯″紡鍦ㄥ彲绉绘妯″紡锛portability mode锛変笅鐢ㄤ簬mysqldump銆
路 NO_UNSIGNED_SUBTRACTION
鍦ㄥ噺杩愮畻涓紝濡傛灉鏌愪釜鎿嶄綔鏁版病鏈夌鍙凤紝涓嶈灏嗙粨鏋滄爣璁颁负UNSIGNED銆傝娉ㄦ剰杩欐牱浣UNSIGNED BIGINT涓嶈兘100%鐢ㄤ簬涓婁笅鏂囦腑銆傚弬瑙12.8鑺傦紝鈥淐ast鍑芥暟鍜屾搷浣滅鈥銆
路 NO_ZERO_DATE
鍦ㄤ弗鏍兼ā寮忥紝涓嶈灏 '0000-00-00'鍋氫负鍚堟硶鏃ユ湡銆備綘浠嶇劧鍙互鐢IGNORE閫夐」鎻掑叆闆舵棩鏈熴傚湪闈炰弗鏍兼ā寮忥紝鍙互鎺ュ彈璇ユ棩鏈燂紝浣嗕細鐢熸垚璀﹀憡銆
路 NO_ZERO_IN_DATE
鍦ㄤ弗鏍兼ā寮忥紝涓嶆帴鍙楁湀鎴栨棩閮ㄥ垎涓0鐨勬棩鏈熴傚鏋滀娇鐢IGNORE閫夐」锛屾垜浠负绫讳技鐨勬棩鏈熸彃鍏'0000-00-00'銆傚湪闈炰弗鏍兼ā寮忥紝鍙互鎺ュ彈璇ユ棩鏈燂紝浣嗕細鐢熸垚璀﹀憡銆
路 ONLY_FULL_GROUP_BY
涓嶈璁GROUP BY閮ㄥ垎涓殑鏌ヨ鎸囧悜鏈夋嫨鐨勫垪銆
路 PIPES_AS_CONCAT
灏||瑙嗕负瀛楃涓茶繛鎺ユ搷浣滅锛堬紜锛(鍚CONCAT())锛岃屼笉瑙嗕负OR銆
路 REAL_AS_FLOAT
灏REAL瑙嗕负FLOAT鐨勫悓涔夎瘝锛岃屼笉鏄DOUBLE鐨勫悓涔夎瘝銆
路 STRICT_TRANS_TABLES
涓烘墍鏈夊瓨鍌ㄥ紩鎿庡惎鐢ㄤ弗鏍兼ā寮忋傞潪娉曟暟鎹艰鎷掔粷銆傚悗闈㈡湁璇︾粏璇存槑銆
路 STRICT_TRANS_TABLES
涓轰簨鍔″瓨鍌ㄥ紩鎿庡惎鐢ㄤ弗鏍兼ā寮忥紝涔熷彲鑳戒负闈炰簨鍔″瓨鍌ㄥ紩鎿庡惎鐢ㄤ弗鏍兼ā寮忋傚悗闈㈡湁璇︾粏璇存槑銆
涓ユ牸妯″紡鎺у埗MySQL濡備綍澶勭悊闈炴硶鎴栦涪澶辩殑杈撳叆鍊笺傛湁鍑犵鍘熷洜鍙互浣夸竴涓间负闈炴硶銆備緥濡傦紝鏁版嵁绫诲瀷閿欒锛屼笉閫傚悎鍒楋紝鎴栬秴鍑鸿寖鍥淬傚綋鏂版彃鍏ョ殑琛屼笉鍖呭惈鏌愬垪鐨勬病鏈夋樉绀哄畾涔DEFAULT瀛愬彞鐨勫硷紝鍒欒鍊艰涓㈠け銆
瀵逛簬浜嬪姟琛紝褰撳惎鐢STRICT_ALL_TABLES鎴STRICT_TRANS_TABLES妯″紡鏃讹紝濡傛灉璇彞涓湁闈炴硶鎴栦涪澶卞硷紝鍒欎細鍑虹幇閿欒銆傝鍙ヨ鏀惧純骞舵粴鍔ㄣ
瀵逛簬闈炰簨鍔¤〃锛屽鏋滄彃鍏ユ垨鏇存柊鐨勭1琛屽嚭鐜板潖鍊硷紝涓ょ妯″紡鐨勮涓虹浉鍚屻傝鍙ヨ鏀惧純锛岃〃淇濇寔涓嶅彉銆傚鏋滆鍙ユ彃鍏ユ垨淇敼澶氳锛屽苟涓斿潖鍊煎嚭鐜板湪绗2鎴栧悗闈㈢殑琛岋紝缁撴灉鍙栧喅浜庡惎鐢ㄤ簡鍝釜涓ユ牸閫夐」锛
路 瀵逛簬STRICT_ALL_TABLES锛MySQL杩斿洖閿欒骞跺拷瑙嗗墿浣欑殑琛屻備絾鏄紝鍦ㄨ繖绉嶆儏鍐典笅锛屽墠闈㈢殑琛屽凡缁忚鎻掑叆鎴栨洿鏂般傝繖璇存槑浣犲彲浠ラ儴鍒嗘洿鏂帮紝杩欏彲鑳戒笉鏄綘鎯宠鐨勩傝閬垮厤杩欑偣锛屾渶濂戒娇鐢ㄥ崟琛岃鍙ワ紝鍥犱负杩欐牱鍙互涓嶆洿鏀硅〃鍗冲彲浠ユ斁寮冦
路 瀵逛簬STRICT_TRANS_TABLES锛MySQL灏嗛潪娉曞艰浆鎹负鏈鎺ヨ繎璇ュ垪鐨勫悎娉曞煎苟鎻掑叆璋冩暣鍚庣殑鍊笺傚鏋滃间涪澶憋紝MySQL鍦ㄥ垪涓彃鍏ラ殣寮 榛樿鍊笺傚湪浠讳綍鎯呭喌涓嬶紝MySQL閮戒細鐢熸垚璀﹀憡鑰屼笉鏄粰鍑洪敊璇苟缁х画鎵ц璇彞銆13.1.5鑺傦紝鈥淐REATE TABLE璇硶鈥鎻忚堪浜嗛殣寮忛粯璁ゅ笺
涓ユ牸妯″紡涓嶅厑璁搁潪娉曟棩鏈燂紝渚嬪'2004-04-31'銆傚畠涓嶅厑璁哥姝㈡棩鏈熶娇鐢ㄢ滈浂鈥濋儴鍒嗭紝渚嬪'2004-04-00'鎴栤闆鈥濇棩鏈熴傝鎯崇姝紝搴斿湪涓ユ牸妯″紡鍩虹涓婏紝鍚敤NO_ZERO_IN_DATE鍜NO_ZERO_DATE SQL妯″紡銆
濡傛灉浣犱笉浣跨敤涓ユ牸妯″紡(鍗充笉鍚敤STRICT_TRANS_TABLES鎴STRICT_ALL_TABLES妯″紡)锛屽浜庨潪娉曟垨涓㈠け鐨勫硷紝MySQL灏嗘彃鍏ヨ皟鏁村悗鐨勫煎苟缁欏嚭璀﹀憡銆傚湪涓ユ牸妯″紡锛屼綘鍙互閫氳繃INSERT IGNORE鎴UPDATE IGNORE鏉ュ疄鐜般傚弬瑙13.5.4.22鑺傦紝鈥淪HOW WARNINGS璇硶鈥銆
涓嬮潰鐨勭壒娈婃ā寮忓揩閫熺粍鍚堜簡鍓嶉潰鎵鍒楃殑妯″紡銆
鍏朵腑鍖呮嫭澶у鏁版渶鏂扮増鏈MySQL涓殑鎵鏈夋ā寮忓笺傛棫鐗堟湰涓紝缁勫悎妯″紡涓嶅寘鎷柊鐗堟湰涓病鏈夌殑涓嶉傜敤鐨勫叿浣撴ā寮忓笺
路 ANSI
绛夊悓REAL_AS_FLOAT銆PIPES_AS_CONCAT銆ANSI_QUOTES銆IGNORE_SPACE銆傚弬瑙1.8.3鑺傦紝鈥滃湪ANSI妯″紡涓嬭繍琛孧ySQL鈥銆
路 DB2
绛夊悓PIPES_AS_CONCAT銆ANSI_QUOTES銆IGNORE_SPACE銆NO_KEY_OPTIONS銆NO_TABLE_OPTIONS銆NO_FIELD_OPTIONS銆
路 MAXDB
绛夊悓PIPES_AS_CONCAT銆ANSI_QUOTES銆IGNORE_SPACE銆NO_KEY_OPTIONS銆NO_TABLE_OPTIONS銆NO_FIELD_OPTIONS銆 NO_AUTO_CREATE_USER銆
路 MSSQL
绛夊悓PIPES_AS_CONCAT銆ANSI_QUOTES銆IGNORE_SPACE銆NO_KEY_OPTIONS銆NO_TABLE_OPTIONS銆 NO_FIELD_OPTIONS銆
路 MYSQL323
绛夊悓NO_FIELD_OPTIONS銆HIGH_NOT_PRECEDENCE銆
路 MYSQL40
绛夊悓NO_FIELD_OPTIONS銆HIGH_NOT_PRECEDENCE銆
路 ORACLE
绛夊悓PIPES_AS_CONCAT銆ANSI_QUOTES銆IGNORE_SPACE銆NO_KEY_OPTIONS銆NO_TABLE_OPTIONS銆NO_FIELD_OPTIONS銆NO_AUTO_CREATE_USER銆
路 POSTGRESQL
绛夊悓PIPES_AS_CONCAT銆ANSI_QUOTES銆IGNORE_SPACE銆NO_KEY_OPTIONS銆NO_TABLE_OPTIONS銆NO_FIELD_OPTIONS銆
路 TRADITIONAL
绛夊悓STRICT_TRANS_TABLES銆丼TRICT_ALL_TABLES銆丯O_ZERO_IN_DATE銆丯O_ZERO_DATE銆丒RROR_FOR_DIVISION_BY_ZERO銆丯O_AUTO_CREATE_USER銆
鏈嶅姟鍣ㄥ皢缁存姢璁稿琛ㄧず鍏堕厤缃殑绯荤粺鍙橀噺銆傛墍鏈夊彉閲忓潎鏈夐粯璁ゅ笺傚彲浠ュ湪鍛戒护琛屼腑鎴栭夐」鏂囦欢璁剧疆閫夐」鍦ㄦ湇鍔″櫒鍚姩鏃跺瀹冧滑杩涜璁剧疆銆傚ぇ澶氭暟鍙互鍦ㄨ繍琛屾椂浣跨敤SET璇彞鏉ヨ缃
mysqld鏈嶅姟鍣缁存姢涓ょ鍙橀噺銆傚叏灞鍙橀噺褰卞搷鏈嶅姟鍣ㄧ殑鍏ㄥ眬鎿嶄綔銆備細璇濆彉閲忓奖鍝嶅叿浣撳鎴风杩炴帴鐩稿叧鎿嶄綔銆
鏈嶅姟鍣ㄥ惎鍔ㄦ椂锛屽皢鎵鏈夊叏灞鍙橀噺鍒濆鍖栦负榛樿鍊笺傚彲浠ュ湪閫夐」鏂囦欢鎴栧懡浠よ涓寚瀹氱殑閫夐」鏉ユ洿鏀硅繖浜涢粯璁ゅ笺傛湇鍔″櫒鍚姩鍚庯紝閫氳繃杩炴帴鏈嶅姟鍣ㄥ苟鎵цSET GLOBAL var_name璇彞鍙互鏇存敼鍔ㄦ佸叏灞鍙橀噺銆傝鎯虫洿鏀瑰叏灞鍙橀噺锛屽繀椤诲叿鏈SUPER鏉冮檺銆
鏈嶅姟鍣ㄨ繕涓烘瘡涓鎴风杩炴帴缁存姢浼氳瘽鍙橀噺銆傝繛鎺ユ椂浣跨敤鐩稿簲鍏ㄥ眬鍙橀噺鐨勫綋鍓嶅煎瀹㈡埛绔細璇濆彉閲忚繘琛屽垵濮嬪寲銆傚鎴峰彲浠ラ氳繃SET SESSION var_name璇彞鏉ユ洿鏀瑰姩鎬佷細璇濆彉閲忋傝缃細璇濆彉閲忎笉闇瑕佺壒娈婃潈闄愶紝浣嗗鎴峰彲浠ュ彧鏇存敼鑷繁鐨勪細璇濆彉閲忥紝鑰屼笉鏇存敼鍏跺畠瀹㈡埛鐨勪細璇濆彉閲忋
浠讳綍璁块棶鍏ㄥ眬鍙橀噺鐨勫鎴风閮藉彲浠ョ湅瑙佸鍏ㄥ眬鍙橀噺鐨勬洿鏀广備絾鏄紝瀹冨彧褰卞搷鍦ㄦ洿鏀瑰悗杩炴帴鐨勪粠璇ュ叏灞鍙橀噺鍒濆鍖栫浉搴斾細璇濆彉閲忕殑瀹㈡埛绔傚畠涓嶄細褰卞搷宸茬粡杩炴帴涓婄殑瀹㈡埛绔殑浼氳瘽鍙橀噺(鐢氳嚦鏄墽琛SET GLOBAL璇彞鐨勫鎴风)銆
褰撲娇鐢ㄥ惎鍔ㄩ夐」璁剧疆鍙橀噺鏃讹紝鍙橀噺鍊煎彲浠ヤ娇鐢ㄥ悗缂K銆M鎴G鍒嗗埆琛ㄧず鍗冨瓧鑺傘佸厗瀛楄妭鎴gigabytes銆備緥濡傦紝涓嬮潰鐨勫懡浠ゅ惎鍔ㄦ湇鍔″櫒鏃剁殑閿肩紦鍐插尯澶у皬涓16 megabytes锛
mysqld --key_buffer_size=16M
鍚庣紑鐨勫ぇ灏忓啓缇庡叧绯伙紱16M鍜16m鏄悓鏍风殑銆
杩愯鏃讹紝浣跨敤SET璇彞鏉ヨ缃郴缁熷彉閲忋傛鏃讹紝涓嶈兘浣跨敤鍚庣紑锛屼絾鍊煎彲浠ラ噰鍙栦笅鍒楄〃杈惧紡锛
mysql> SET sort_buffer_size = 10 * 1024 * 1024;
瑕佹兂鏄惧紡鎸囧畾鏄惁璁剧疆鍏ㄥ眬鎴栦細璇濆彉閲忥紝浣跨敤GLOBAL鎴SESSION閫夐」锛
mysql> SET GLOBAL sort_buffer_size = 10 * 1024 * 1024;
mysql> SET SESSION sort_buffer_size = 10 * 1024 * 1024;
涓や釜閫夐」鍧囨病鏈夛紝鍒欒鍙ヨ缃細璇濆彉閲忋
5.3.3.1鑺傦紝鈥滃姩鎬佺郴缁熷彉閲忊涓垪鍑轰簡鍙互鍦ㄨ繍琛屾椂璁剧疆鐨勫彉閲忋
濡傛灉浣犳兂鐢SET璇彞闄愬埗绯荤粺鍙橀噺鍙鐨勬渶澶у硷紝鍙互鍦ㄦ湇鍔″櫒鍚姩鏃堕氳繃--maximum-var_name褰㈠紡鐨勯夐」鏉ユ寚瀹氥備緥濡傦紝瑕佹兂闃叉query_cache_size鐨勫艰繍琛屾椂瓒呰繃32MB锛屼娇鐢ㄩ夐」--maximum-query_cache_size=32M銆
浣犲彲浠ラ氳繃SHOW VARIABLES璇彞鏌ョ湅绯荤粺鍙橀噺鍙婂叾鍊笺傝缁嗕俊鎭弬瑙9.4鑺傦紝鈥滅郴缁熷彉閲忊銆
mysql> SHOW VARIABLES; +---------------------------------+-------------------------------------------+ | Variable_name | Value | +---------------------------------+-------------------------------------------+ | auto_increment_increment | 1 | | auto_increment_offset | 1 | | automatic_sp_privileges | ON | | back_log | 50 | | basedir | /home/jon/bin/mysql/ | | binlog_cache_size | 32768 | | bulk_insert_buffer_size | 8388608 | | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | latin1 | | character_set_results | latin1 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /home/jon/bin/mysql/share/mysql/charsets/ | | collation_connection | latin1_swedish_ci | | collation_database | latin1_swedish_ci | | collation_server | latin1_swedish_ci | | completion_type | 0 | | concurrent_insert | 1 | | connect_timeout | 5 | | datadir | /home/jon/bin/mysql/var/ | | date_format | %Y-%m-%d | | datetime_format | %Y-%m-%d %H:%i:%s | | default_week_format | 0 | | delay_key_write | ON | | delayed_insert_limit | 100 | | delayed_insert_timeout | 300 | | delayed_queue_size | 1000 | | div_precision_increment | 4 | | engine_condition_pushdown | OFF | | expire_logs_days | 0 | | flush | OFF | | flush_time | 0 | | ft_boolean_syntax | + -><()~*:""&| | | ft_max_word_len | 84 | | ft_min_word_len | 4 | | ft_query_expansion_limit | 20 | | ft_stopword_file | (built-in) | | group_concat_max_len | 1024 | | have_archive | YES | | have_bdb | NO | | have_blackhole_engine | YES | | have_compress | YES | | have_crypt | YES | | have_csv | YES | | have_example_engine | NO | | have_federated_engine | NO | | have_geometry | YES | | have_innodb | YES | | have_isam | NO | | have_ndbcluster | DISABLED | | have_openssl | NO | | have_partition_engine | YES | | have_query_cache | YES | | have_raid | NO | | have_rtree_keys | YES | | have_symlink | YES | | init_connect | | | init_file | | | init_slave | | | innodb_additional_mem_pool_size | 1048576 | | innodb_autoextend_increment | 8 | | innodb_buffer_pool_awe_mem_mb | 0 | | innodb_buffer_pool_size | 8388608 | | innodb_checksums | ON | | innodb_commit_concurrency | 0 | | innodb_concurrency_tickets | 500 | | innodb_data_file_path | ibdata1:10M:autoextend | | innodb_data_home_dir | | | innodb_doublewrite | ON | | innodb_fast_shutdown | 1 | | innodb_file_io_threads | 4 | | innodb_file_per_table | OFF | | innodb_flush_log_at_trx_commit | 1 | | innodb_flush_method | | | innodb_force_recovery | 0 | | innodb_lock_wait_timeout | 50 | | innodb_locks_unsafe_for_binlog | OFF | | innodb_log_arch_dir | | | innodb_log_archive | OFF | | innodb_log_buffer_size | 1048576 | | innodb_log_file_size | 5242880 | | innodb_log_files_in_group | 2 | | innodb_log_group_home_dir | ./ | | innodb_max_dirty_pages_pct | 90 | | innodb_max_purge_lag | 0 | | innodb_mirrored_log_groups | 1 | | innodb_open_files | 300 | | innodb_support_xa | ON | | innodb_sync_spin_loops | 20 | | innodb_table_locks | ON | | innodb_thread_concurrency | 20 | | innodb_thread_sleep_delay | 10000 | | interactive_timeout | 28800 | | join_buffer_size | 131072 | | key_buffer_size | 8388600 | | key_cache_age_threshold | 300 | | key_cache_block_size | 1024 | | key_cache_division_limit | 100 | | language | /home/jon/bin/mysql/share/mysql/english/ | | large_files_support | ON | | large_page_size | 0 | | large_pages | OFF | | license | GPL | | local_infile | ON | | locked_in_memory | OFF | | log | ON | | log_bin | ON | | log_bin_trust_routine_creators | OFF | | log_error | /home/jon/bin/mysql/var/master1.err | | log_slave_updates | OFF | | log_slow_queries | OFF | | log_warnings | 1 | | long_query_time | 10 | | low_priority_updates | OFF | | lower_case_file_system | OFF | | lower_case_table_names | 0 | | max_allowed_packet | 1048576 | | max_binlog_cache_size | 4294967295 | | max_binlog_size | 1073741824 | | max_connect_errors | 10 | | max_connections | 100 | | max_delayed_threads | 20 | | max_error_count | 64 | | max_heap_table_size | 16777216 | | max_insert_delayed_threads | 20 | | max_join_size | 4294967295 | | max_length_for_sort_data | 1024 | | max_relay_log_size | 0 | | max_seeks_for_key | 4294967295 | | max_sort_length | 1024 | | max_tmp_tables | 32 | | max_user_connections | 0 | | max_write_lock_count | 4294967295 | | multi_range_count | 256 | | myisam_data_pointer_size | 6 | | myisam_max_sort_file_size | 2147483647 | | myisam_recover_options | OFF | | myisam_repair_threads | 1 | | myisam_sort_buffer_size | 8388608 | | ndb_autoincrement_prefetch_sz | 32 | | ndb_cache_check_time | 0 | | ndb_force_send | ON | | ndb_index_stat_cache_entries | 32 | | ndb_index_stat_enable | ON | | ndb_index_stat_update_freq | 20 | | ndb_use_exact_count | ON | | ndb_use_transactions | ON | | net_buffer_length | 16384 | | net_read_timeout | 30 | | net_retry_count | 10 | | net_write_timeout | 60 | | new | OFF | | old_alter_table | OFF | | old_passwords | OFF | | open_files_limit | 1024 | | optimizer_prune_level | 1 | | optimizer_search_depth | 62 | | pid_file | /home/jon/bin/mysql/var/hostname.pid1 | | port | 3306 | | preload_buffer_size | 32768 | | protocol_version | 10 | | query_alloc_block_size | 8192 | | query_cache_limit | 1048576 | | query_cache_min_res_unit | 4096 | | query_cache_size | 0 | | query_cache_type | ON | | query_cache_wlock_invalidate | OFF | | query_prealloc_size | 8192 | | range_alloc_block_size | 2048 | | read_buffer_size | 131072 | | read_only | OFF | | read_rnd_buffer_size | 262144 | | relay_log_purge | ON | | relay_log_space_limit | 0 | | rpl_recovery_rank | 0 | | secure_auth | OFF | | server_id | 1 | | skip_external_locking | ON | | skip_networking | OFF | | skip_show_database | OFF | | slave_compressed_protocol | OFF | | slave_load_tmpdir | /tmp/ | | slave_net_timeout | 3600 | | slave_skip_errors | OFF | | slave_transaction_retries | 10 | | slow_launch_time | 2 | | socket | /tmp/mysql.sock | | sort_buffer_size | 2097144 | | sql_mode | | | sql_notes | ON | | sql_warnings | ON | | storage_engine | MyISAM | | sync_binlog | 0 | | sync_frm | ON | | sync_replication | 0 | | sync_replication_slave_id | 0 | | sync_replication_timeout | 10 | | system_time_zone | EST | | table_cache | 64 | | table_lock_wait_timeout | 50 | | table_type | MyISAM | | thread_cache_size | 0 | | thread_stack | 196608 | | time_format | %H:%i:%s | | time_zone | SYSTEM | | timed_mutexes | OFF | | tmp_table_size | 33554432 | | tmpdir | | | transaction_alloc_block_size | 8192 | | transaction_prealloc_size | 4096 | | tx_isolation | REPEATABLE-READ | | updatable_views_with_limit | YES | | version | 5.1.2-alpha-log | | version_comment | Source distribution | | version_compile_machine | i686 | | version_compile_os | suse-linux | | wait_timeout | 28800 | +---------------------------------+-------------------------------------------+ 218 rows in set (0.03 sec)
姝ゅ鎻忚堪浜嗗ぇ澶氭暟绯荤粺鍙橀噺銆傛病鏈夌増鏈殑鍙橀噺鍦ㄦ墍鏈MySQL 5.1 鍙戝竷涓傜敤銆傚叧浜庡叾浣跨敤鍘嗗彶淇℃伅锛岃鍙傝MySQL 5.0鍙傝冩寚鍗鍜MySQL 4.1鍙傝冩寚鍗銆InnoDB绯荤粺鍙橀噺鍒椾簬 15.2.4鑺傦紝鈥淚nnoDB鍚姩閫夐」鈥銆
鑻ユ病鏈夊彟琛岃瀹氾紝缂撳啿鍖哄ぇ灏忋侀暱搴﹀拰鍫嗘爤澶у皬鐨勫崟浣嶅潎涓哄瓧鑺傘
鍏充簬杩欎簺鍙橀噺鐨勮皟鑺備俊鎭弬瑙7.5.2鑺傦紝鈥滆皟鑺傛湇鍔″櫒鍙傛暟鈥銆
路 auto_increment_increment
auto_increment_increment鍜auto_increment_offset鐢ㄤ簬涓绘湇鍔″櫒锛嶄富鏈嶅姟鍣紙master-to-master锛夊鍒讹紝骞跺彲浠ョ敤鏉ユ帶鍒AUTO_INCREMENT鍒楃殑鎿嶄綔銆備袱涓彉閲忓潎鍙互璁剧疆涓哄叏灞鎴栧眬閮ㄥ彉閲忥紝骞朵笖鍋囧畾姣忎釜鍊奸兘鍙互涓1鍒65,535涔嬮棿鐨勬暣鏁板笺傚皢鍏朵腑涓涓彉閲忚缃负0浼氫娇璇ュ彉閲忎负1銆傚鏋滆瘯鍥惧皢杩欎簺鍙橀噺璁剧疆涓哄ぇ浜65,535鎴栧皬浜0鐨勫硷紝鍒欎細灏嗚鍊艰缃负65,535銆傚鏋滃悜灏auto_increment_increment鎴auto_increment_offset璁剧疆涓洪潪鏁存暟鍊硷紝鍒欎細缁欏嚭閿欒锛屽苟涓斿彉閲忕殑瀹為檯鍊煎湪杩欑鎯呭喌涓嬩繚鎸佷笉鍙樸
杩欎袱涓彉閲忓奖鍝AUTO_INCREMENT鍒楃殑鏂瑰紡锛
o auto_increment_increment鎺у埗鍒椾腑鐨勫肩殑澧為噺鍊笺備緥濡:
o mysql> SHOW VARIABLES LIKE 'auto_inc%';
o +--------------------------+-------+
o | Variable_name | Value |
o +--------------------------+-------+
o | auto_increment_increment | 1 |
o | auto_increment_offset | 1 |
o +--------------------------+-------+
o 2 rows in set (0.00 sec)
o
o mysql> CREATE TABLE autoinc1 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
o Query OK, 0 rows affected (0.04 sec)
o
o mysql> SET @auto_increment_increment=10;
o Query OK, 0 rows affected (0.00 sec)
o
o mysql> SHOW VARIABLES LIKE 'auto_inc%';
o +--------------------------+-------+
o | Variable_name | Value |
o +--------------------------+-------+
o | auto_increment_increment | 10 |
o | auto_increment_offset | 1 |
o +--------------------------+-------+
o 2 rows in set (0.01 sec)
o
o mysql> INSERT INTO autoinc1 VALUES (NULL), (NULL), (NULL), (NULL);
o Query OK, 4 rows affected (0.00 sec)
o Records: 4 Duplicates: 0 Warnings: 0
o
o mysql> SELECT col FROM autoinc1;
o +-----+
o | col |
o +-----+
o | 1 |
o | 11 |
o | 21 |
o | 31 |
o +-----+
o 4 rows in set (0.00 sec)
(娉ㄦ槑濡備綍浣跨敤SHOW VARIABLES鏉ヨ幏鍙栬繖浜涘彉閲忕殑褰撳墠鍊硷級銆
o auto_increment_offset纭畾AUTO_INCREMENT鍒楀肩殑璧风偣銆傚亣瀹氬湪涓庡墠闈㈢殑渚嬪瓙鐨勭浉鍚岀殑浼氳瘽涓墽琛屼笅闈㈢殑鍛戒护锛
o mysql> SET @auto_increment_offset=5;
o Query OK, 0 rows affected (0.00 sec)
o
o mysql> SHOW VARIABLES LIKE 'auto_inc%';
o +--------------------------+-------+
o | Variable_name | Value |
o +--------------------------+-------+
o | auto_increment_increment | 10 |
o | auto_increment_offset | 5 |
o +--------------------------+-------+
o 2 rows in set (0.00 sec)
o
o mysql> CREATE TABLE autoinc2 (col INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
o Query OK, 0 rows affected (0.06 sec)
o
o mysql> INSERT INTO autoinc2 VALUES (NULL), (NULL), (NULL), (NULL);
o Query OK, 4 rows affected (0.00 sec)
o Records: 4 Duplicates: 0 Warnings: 0
o
o mysql> SELECT col FROM autoinc2;
o +-----+
o | col |
o +-----+
o | 5 |
o | 15 |
o | 25 |
o | 35 |
o +-----+
o 4 rows in set (0.02 sec)
o
濡傛灉auto_increment_offset鐨勫煎ぇ浜auto_increment_increment鐨勫硷紝鍒auto_increment_offset鐨勫艰蹇界暐銆
濡傛灉鍏朵腑涓涓垨涓や釜鍙橀噺琚洿鏀逛簡锛岀劧鍚庢洿鏀规彃鍏ュ埌鍖呭惈AUTO_INCREMENT鍒楃殑琛ㄤ腑鐨勬柊琛岋紝缁撴灉鍙兘鐪嬩笂鍘绘湁闂锛岀敱浜庤绠AUTO_INCREMENT绯诲垪鍊兼椂娌℃湁鑰冭檻鍒楀唴宸茬粡瀛樺湪鐨勫硷紝骞朵笖鎻掑叆鐨勪笅涓涓兼槸鍒楀唴鏈灏忕殑鍊硷紝澶т簬AUTO_INCREMENT鍒楀唴宸叉湁鐨勬渶澶у笺傛崲鍙ヨ瘽璇达紝鏁板肩殑璁$畻鏂规硶涓猴細
auto_increment_offset+ N * auto_increment_increment
鍏朵腑N涓虹郴鍒楀唴鐨勬鏁存暟鍊[1,2,3,...]銆備緥濡傦細
mysql> SHOW VARIABLES LIKE 'auto_inc%';
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| auto_increment_increment | 10 |
| auto_increment_offset | 5 |
+--------------------------+-------+
2 rows in set (0.00 sec)
mysql> SELECT col FROM autoinc1;
+-----+
| col |
+-----+
| 1 |
| 11 |
| 21 |
| 31 |
+-----+
4 rows in set (0.00 sec)
mysql> INSERT INTO autoinc1 VALUES (NULL), (NULL), (NULL), (NULL);
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> SELECT col FROM autoinc1;
+-----+
| col |
+-----+
| 1 |
| 11 |
| 21 |
| 31 |
| 35 |
| 45 |
| 55 |
| 65 |
+-----+
8 rows in set (0.00 sec)
auto_increment_increment鍜auto_increment_offset鎵绀虹殑鍊煎彲浠ョ敓鎴愮郴鍒5 + N * 10,鍗筹紝[5,15,25,35,45,...]銆傚湪INSERT鍓col 鍒楀唴鏈澶х殑鍊间负31,AUTO_INCREMENT鏁板垪鐨勪笅涓涓间负35,鍥犳col涓彃鍏ョ殑鍊间粠璇ョ偣寮濮嬶紝缁撴灉濡SELECT鏌ヨ鎵绀恒
涓瀹氳璁颁綇涓嶅彲鑳藉皢杩欎袱涓彉閲忕殑缁撴灉闄愬埗鍒颁竴涓〃涓紝鍥犳涓嶄細鏇夸唬鍏跺畠鏁版嵁搴撶鐞嗙郴缁熸彁渚涚殑搴忓垪锛涜繖浜涘彉閲忔帶鍒MySQL鏈嶅姟鍣ㄤ笂all琛AUTO_INCREMENT鍒楃殑鎵鏈夎涓恒傚鏋滄煇涓彉閲忚涓哄叏灞鍙橀噺锛屽垯鍙湁閫氳繃灞閮ㄨ缃皢鍏ㄥ眬鍊兼洿鏀瑰拰瑕嗙洊鍚庢垨mysqld閲嶅惎鍚庡叾浣滅敤鏂瑰彲鏀瑰彉锛涘鏋滃眬閮ㄨ缃紝鍒欐柊鍊煎奖鍝嶆墍鏈夎〃鐨AUTO_INCREMENT鍒楋紝鍦ㄨ繖涓細璇濇湡闂村綋鍓嶇敤鎴峰湪杩欎簺琛ㄤ腑鎻掑叆浜嗘柊琛岋紝闄ら潪鍦ㄤ細璇濇湡闂存洿鏀逛簡杩欎簺鍊笺
auto_increment_increment鐨 榛樿鍊间负1銆傚弬瑙6.12鑺傦紝鈥滃鏈嶅姟鍣ㄥ鍒朵腑鐨凙uto-Increment鈥銆
路 auto_increment_offset
璇ュ彉閲忕殑榛樿鍊间负1銆傝瑙auto_increment_increment鐨勬弿杩般
路 back_log
MySQL鏈夌殑涓昏杩炴帴璇锋眰鐨勬暟閲忋傚綋涓MySQL绾跨▼鍦ㄧ煭鏃堕棿鍐呭緱鍒拌澶氳繛鎺ヨ姹傛椂鍙戞尌浣滅敤銆備富绾跨▼闇瑕佽姳涓浜涙椂闂(灏界寰堝皯)鏉ユ鏌ヨ繛鎺ュ苟鍚姩涓涓柊绾跨▼銆back_log鍊艰鏄MySQL涓存椂鍋滄鍝嶅簲鏂拌姹傚墠鍦ㄧ煭鏃堕棿鍐呭彲浠ュ爢璧峰灏戣姹傘傚鏋滀綘闇瑕佸湪鐭椂闂村唴鍏佽澶ч噺杩炴帴锛屽彲浠ュ鍔犺鏁板笺
鎹㈠彞璇濊锛岃鍊间负鈥滆繘鈥TCP/IP杩炴帴甯у惉闃熷垪鐨勫ぇ灏忋傛搷浣滅郴缁熸湁璇ラ槦鍒楄嚜宸辩殑闄愬埗鍊笺傛湰鎵嬪唽涓Unix listen()绯荤粺璋冪敤椤靛簲鏈夋洿璇︾粏鐨勪俊鎭傝鍙橀噺鏈澶у艰鏌ラ槄OS鏂囨。銆備紒鍥惧皢back_log璁剧疆涓洪珮浜庝綘鐨勬搷浣滅郴缁熼檺鍊兼槸寰掑姵鏃犵泭鐨勩
路 basedir
MySQL瀹夎鍩哄噯鐩綍銆傚彲浠ョ敤--basedir閫夐」璁剧疆璇ュ彉閲忋
路 bdb_cache_size
涓BDB琛ㄧ紦瀛樼储寮曞拰琛屽垎閰嶇殑缂撳啿鍖虹殑澶у皬銆傚鏋滀綘涓嶄娇鐢BDB琛紝浣犲簲鐢--skip-bdb鍚姩mysqld浠ヤ究涓嶆氮璐硅缂撳瓨銆
路 bdb_home
BDB琛ㄥ熀鍑嗙洰褰曘傚簲涓datadir鍙橀噺鐨勫肩浉鍚屻
路 bdb_log_buffer_size
涓BDB琛ㄧ紦瀛樼储寮曞拰琛屽垎閰嶇殑缂撳啿鍖虹殑澶у皬銆傚鏋滀綘涓嶄娇鐢BDB琛紝浣犲簲灏嗚鍊艰缃负0鎴栫敤--skip-bdb鍚姩mysqld浠ヤ究涓嶆氮璐硅缂撳瓨銆
路 bdb_logdir
BDB瀛樺偍寮曟搸鍐欏畠鏃ュ織鏂囦欢鐨勭洰褰曘傚彲浠ョ敤--bdb-logdir閫夐」璁剧疆璇ュ彉閲忋
路 bdb_max_lock
鍦BDB琛ㄤ笅鍙互婵娲荤殑鏈澶ч攣鏁(榛樿涓10,000)銆傚鏋滃綋浣犳墽琛岄暱浜嬪姟鎴栧綋mysqld蹇呴』妫鏌ヨ澶氳鏉ヨ绠楁煡璇㈡椂鍑虹幇涓嬮潰鐨勯敊璇紝浣犲簲澧炲姞璇ュ硷細
bdb: Lock table is out of available locks
Got error 12 from ...
路 bdb_shared_data
濡傛灉浣犳浣跨敤--bdb-shared-data搴斾负ON銆
路 bdb_tmpdir
--bdb-tmpdir閫夐」鐨勫笺
路 binlog_cache_size
鍦ㄤ簨鍔¤繃绋嬩腑瀹圭撼浜岃繘鍒舵棩蹇SQL璇彞鐨勭紦瀛樺ぇ灏忋備簩杩涘埗鏃ュ織缂撳瓨鏄湇鍔″櫒鏀寔浜嬪姟瀛樺偍寮曟搸骞朵笖鏈嶅姟鍣ㄥ惎鐢ㄤ簡浜岃繘鍒舵棩蹇(--log-bin閫夐」)鐨勫墠鎻愪笅涓烘瘡涓鎴风鍒嗛厤鐨勫唴瀛樸傚鏋滀綘缁忓父浣跨敤澶х殑锛屽璇彞浜嬪姟锛屼綘鍙互澧炲姞璇ュ间互鑾峰緱鏇存湁鐨勬ц兘銆Binlog_cache_use鍜Binlog_cache_disk_use鐘舵佸彉閲忓彲浠ョ敤鏉ヨ皟鏁磋鍙橀噺鐨勫ぇ灏忋傚弬瑙5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆
路 bulk_insert_buffer_size
MyISAM 浣跨敤涓撶敤鏍戠姸缂撳瓨鏉ヤ娇INSERT ... SELECT銆INSERT ... VALUES (...)銆(...)銆 ...鍜LOAD DATA INFILE鐨勫ぇ鍧楁彃鍏ユ洿蹇傝鍙橀噺鐢ㄦ瘡绾跨▼鐨勫瓧鑺傛暟闄愬埗缂撳瓨鏍戠殑澶у皬銆傚皢瀹冭缃负0绂佺敤浼樺寲銆娉閲婏細鍙湁鍚戦潪绌鸿〃娣诲姞鏁版嵁鏃舵墠浣跨敤璇ョ紦瀛樸 榛樿鍊兼槸8MB銆
路 character_set_client
鏉ヨ嚜瀹㈡埛绔殑璇彞鐨勫瓧绗﹂泦銆
路 character_set_connection
鐢ㄤ簬娌℃湁瀛楃闆嗗鍏ョ鐨勬枃瀛楀拰鏁板瓧锛嶅瓧绗︿覆杞崲銆
路 character_set_database
榛樿鏁版嵁搴撲娇鐢ㄧ殑瀛楃闆嗐傚綋榛樿鏁版嵁搴撴洿鏀规椂锛屾湇鍔″櫒鍒欒缃鍙橀噺銆傚鏋滄病鏈夐粯璁ゆ暟鎹簱锛屽彉閲忕殑鍊煎悓character_set_server銆
路 character_set_results
鐢ㄤ簬鍚戝鎴风杩斿洖鏌ヨ缁撴灉鐨勫瓧绗﹂泦銆
路 character_set_ server
鏈嶅姟鍣ㄧ殑榛樿瀛楃闆嗐
路 character_set_system
鏈嶅姟鍣ㄧ敤鏉ヤ繚瀛樿瘑鍒鐨勫瓧绗﹂泦銆傝鍊间竴瀹氭槸utf8銆
路 character_sets_dir
瀛楃闆嗗畨瑁呯洰褰曘
路 collation_connection
杩炴帴瀛楃闆嗙殑鏍″瑙勫垯銆
路 collation_database
榛樿鏁版嵁搴撲娇鐢ㄧ殑鏍″瑙勫垯銆傚綋榛樿鏁版嵁搴撴敼鍙樻椂鏈嶅姟鍣ㄥ垯璁剧疆璇ュ彉閲忋傚鏋滄病鏈夐粯璁ゆ暟鎹簱锛屽彉閲忕殑鍊煎悓collation_server銆
路 collation_server
鏈嶅姟鍣ㄧ殑榛樿鏍″瑙勫垯銆
路 completion_type
浜嬪姟缁撴潫绫诲瀷锛
o 濡傛灉璇ュ间负0(榛樿)锛COMMIT鍜ROLLBACK涓嶅彈褰卞搷銆
o 濡傛灉璇ュ间负1锛COMMIT鍜ROLLBACK鍒嗗埆绛夊悓浜COMMIT AND CHAIN鍜ROLLBACK AND CHAIN銆(鏂颁簨鍔$敤鍒氬垰缁撴潫鐨勪簨鍔$浉鍚岀殑闂撮殧绛夌骇绔嬪嵆鍚姩锛銆
o 濡傛灉璇ュ间负2锛COMMIT鍜ROLLBACK鍒嗗埆绛夊悓浜COMM瀹RELEASE鍜ROLLBACK RELEASE銆(浜嬪姟缁堟鍚庯紝鏈嶅姟鍣ㄦ柇寮锛銆
路 concurrent_insert
濡傛灉涓ON(榛樿鍊)锛MySQL鍏佽INSERT鍜SELECT璇彞鍦ㄤ腑闂存病鏈夌┖鏁版嵁鍧楃殑MyISAM琛ㄤ腑骞惰杩愯銆備綘鍙互鐢--safe鎴--skip-new鍚姩mysqld鍏抽棴璇ラ夐」銆
璇ュ彉閲忎负鏁存暟锛屾湁3涓硷細
鍊 |
鎻忚堪 |
0 |
鍏 |
1 |
(榛樿)鍦ㄦ病鏈夌┖鏁版嵁鍧楃殑MyISAM琛ㄤ腑鍚敤骞惰鎻掑叆 |
2 |
涓烘墍鏈MyISAM琛ㄥ惎鐢ㄥ苟琛屾彃鍏ャ傚鏋滆〃鏈夌┖璁板綍鎴栨琚彟涓绾跨▼浣跨敤锛屾柊琛屽皢鎻掑叆鍒拌〃鐨勬渶鍚庛傚鏋滆〃鏈娇鐢紝MySQL灏嗚繘琛屾櫘閫氳閿佸畾骞跺皢鏂拌鎻掑叆绌鸿褰曘 |
路 connect_timeout
mysqld鏈嶅姟鍣鐢Bad handshake鍝嶅簲鍓嶇瓑寰呰繛鎺ュ寘鐨勭鏁般
路 datadir
MySQL鏁版嵁鐩綍銆傚彲浠ョ敤--datadir閫夐」璁剧疆璇ュ彉閲忋
路 date_format
璇ュ彉閲忔湭浣跨敤銆
路 datetime_format
璇ュ彉閲忔湭浣跨敤銆
路 default_week_format
WEEK() 鍑芥暟浣跨敤鐨勯粯璁ゆā寮忋
路 delay_key_write
璇ラ夐」鍙傜敤MyISAM琛ㄣ傚畠鍏锋湁涓嬭堪鍊煎彲浠ュ奖鍝CREATE TABLE璇彞浣跨敤鐨DELAY_KEY_WRITE琛ㄩ夐」鐨勫鐞嗐
閫夐」 |
鎻忚堪 |
OFF |
DELAY_KEY_WRITE琚拷鐣ャ |
ON |
MySQL鍦CREATE TABLE涓敤DELAY_KEY_WRITE閫夐」銆傝繖鏄 榛樿鍊笺 |
ALL |
鐢ㄥ惎鐢DELAY_KEY_WRITE閫夐」鍒涘缓琛ㄧ殑鐩稿悓鏂规硶瀵规墍鏈夋柊鎵撳紑琛ㄧ殑杩涜澶勭悊銆 |
濡傛灉鍚敤浜DELAY_KEY_WRITE锛岃鏄庝娇鐢ㄨ椤圭殑琛ㄧ殑閿紦鍐插尯鍦ㄦ瘡娆℃洿鏂扮储寮曟椂涓嶈娓呯┖锛屽彧鏈夊叧闂〃鏃舵墠娓呯┖銆傞伄鎺╃洊鍙互澶уぇ鍔犲揩閿殑鍐欐搷浣滐紝浣嗗鏋滀綘浣跨敤璇ョ壒鎬э紝浣犲簲鐢--myisam-recover閫夐」鍚姩鏈嶅姟鍣紝涓烘墍鏈MyISAM琛ㄦ坊鍔犺嚜鍔ㄦ鏌(渚嬪锛--myisam-recover=BACKUP,FORCE)銆傚弬瑙5.3.1鑺傦紝鈥mysqld鍛戒护琛岄夐」鈥鍜15.1.1鑺傦紝鈥淢yISAM鍚姩閫夐」鈥銆
璇锋敞鎰--external-locking涓嶄负浣跨敤寤惰繜閿啓鍏ョ殑琛ㄦ彁渚涚储寮曠牬鍧忎繚鎶ゃ
路 delayed_insert_limit
鎻掑叆delayed_insert_limit 寤惰繜琛屽悗锛INSERT DELAYED 澶勭悊鍣ㄧ嚎绋嬫鏌ユ槸鍚︽湁鎸傝捣鐨SELECT璇彞銆傚鏋滄湁锛屽湪缁х画鎻掑叆寤惰繜鐨勮涔嬪墠锛屽厑璁稿畠浠厛鎵ц銆
路 delayed_insert_timeout
INSERT DELAYED澶勭悊鍣ㄧ嚎绋嬬粓姝㈠墠搴旂瓑寰INSERT璇彞鐨勬椂闂淬
路 delayed_queue_size
杩欐槸鍚勪釜琛ㄤ腑澶勭悊INSERT DELAYED璇彞鏃堕槦鍒椾腑琛岀殑鏁伴噺闄愬埗銆傚鏋滈槦鍒楁弧浜嗭紝鎵цINSERT DELAYED璇彞鐨勫鎴风搴旂瓑寰呯洿鍒伴槦鍒楀唴鍐嶆湁绌洪棿銆
路 div_precision_increment
璇ュ彉閲忚鏄庣敤/鎿嶄綔绗︽墽琛岄櫎鎿嶄綔鐨勭粨鏋滃彲澧炲姞鐨勭簿纭害鐨勪綅鏁般 榛樿鍊兼槸4銆傛渶灏忓拰鏈澶у煎垎鍒负0鍜30銆備笅闈㈢殑绀轰緥璇存槑浜嗗鍔 榛樿鍊肩殑缁撴灉銆
mysql> SELECT 1/7;
+--------+
| 1/7 |
+--------+
| 0.1429 |
+--------+
mysql> SET div_precision_increment = 12;
mysql> SELECT 1/7;
+----------------+
| 1/7 |
+----------------+
| 0.142857142857 |
+----------------+
路 engine_condition_pushdown
璇ュ彉閲忛傜敤浜NDB銆傞粯璁ゅ间负0(OFF)锛氬鏋滀綘鎵ц绫讳技鏌ヨSELECT * FROM t WHERE mycol = 42锛屽叾涓mycol涓烘病鏈夌储寮曠殑鍒楋紝褰撴弧浜嗙殑琛ㄦ壂鎻忔瘡涓NDB鑺傜偣鏃讹紝鎵ц璇ユ煡璇€傛瘡涓妭鐐逛娇鐢WHERE鏉′欢灏嗘瘡涓琛屽彂閫佺粰MySQL鏈嶅姟鍣ㄣ傚鏋engine_condition_pushdown琚缃负1(ON)锛岃鏉′欢鈥pushed down鈥濈粰瀛樺偍寮曟搸骞跺彂閫佺粰NDB鑺傜偣銆傛瘡涓妭鐐归兘鎵ц鎵弿锛屽苟鍙悜MySQL鏈嶅姟鍣ㄥ彂閫佸洖鍖归厤鏉′欢鐨勮銆
路 expire_logs_days
浜岃繘鍒舵棩蹇楄嚜鍔ㄥ垹闄ょ殑澶╂暟銆傞粯璁ゅ间负0,琛ㄧず鈥滄病鏈鑷姩鍒犻櫎鈥濄傚惎鍔ㄦ椂鍜屼簩杩涘埗鏃ュ織寰幆鏃跺彲鑳藉垹闄ゃ
路 flush
濡傛灉鐢--flush閫夐」鍚姩mysqld璇ュ间负ON銆
路 flush_time
濡傛灉璁句负闈為浂鍊硷紝姣忛殧flush_time绉掑垯鍏抽棴鎵鏈夎〃浠ラ噴鏀剧‖鐩樿祫婧愬苟鍚屾鏈竻绌虹殑鏁版嵁銆傛垜浠缓璁彧鍦Windows 9x鎴Me锛屾垨鏈夋渶灏忚祫婧愮殑绯荤粺涓娇鐢ㄨ閫夐」銆
路 ft_boolean_syntax
浣跨敤IN BOOLEAN MODE鎵ц鐨勫竷灏斿叏鏂囨悳绱㈡敮鎸佺殑鎿嶄綔绗︾郴鍒椼傚弬瑙12.7.1鑺傦紝鈥滃竷灏斿叏鏂囨悳绱⑩銆
榛樿鍙橀噺鍊间负 '+ -><()~*:""&|'銆傛洿鏀硅繖浜涘肩殑瑙勫垯鏄細
o 鎿嶄綔绗﹀嚱鏁扮敱鍏跺湪瀛楃涓插唴鐨勪綅缃喅瀹氥
o 鏇挎崲鍊煎繀椤绘槸14涓瓧绗︺
o 姣忎釜瀛楃蹇呴』涓ASCII鐮侀潪鏂囧瓧鏁板瓧瀛楃銆
o 绗1涓垨绗2涓瓧绗﹀繀椤讳负绌烘牸銆
o 闄ら潪璇彞鍦ㄧ11涓瓧绗﹀拰绗12涓瓧绗﹀寮曠敤浜嗘搷浣滅锛屽惁鍒欎笉鍏佽澶嶅埗銆傝繖涓や釜瀛楃鍙互涓嶇浉鍚岋紝浣嗚繖鏄敮涓鍙兘鐨勪袱涓
o 浣嶇疆10銆13鍜14(榛樿璁剧疆涓衡:鈥欍佲&鈥欏拰鈥|鈥)淇濈暀鐢ㄤ簬灏嗘潵鎵╁睍銆
路 ft_max_word_len
FULLTEXT绱㈠紩涓墍鍖呭惈鐨勫瓧鐨勬渶澶ч暱搴︺
娉閲婏細鏇存敼璇ュ彉閲忓悗蹇呴』閲嶅缓FULLTEXT绱㈠紩銆傚簲浣跨敤REPAIR TABLE tbl_name QUICK銆
路 ft_min_word_len
FULLTEXT绱㈠紩涓墍鍖呭惈鐨勫瓧鐨勬渶灏忛暱搴︺
娉閲婏細鏇存敼璇ュ彉閲忓悗蹇呴』閲嶅缓FULLTEXT绱㈠紩銆傚簲浣跨敤REPAIR TABLE tbl_name QUICK銆
路 ft_query_expansion_limit
浣跨敤WITH QUERY EXPANSION杩涜鍏ㄦ枃鎼滅储鐨勬渶澶у尮閰嶆暟銆
路 ft_stopword_file
鐢ㄤ簬璇诲彇鍏ㄦ枃鎼滅储鐨勫仠姝㈠瓧娓呭崟鐨勬枃浠躲傝鏂囦欢涓殑鎵鏈夊瓧閮戒細鐢ㄥ埌锛涙敞閲婁笉閲嶈銆傞粯璁ゆ儏鍐典笅锛屼娇鐢ㄥ唴宓屽紡鍋滄瀛楁竻鍗(濡myisam/ft_static.c鏂囦欢涓墍瀹氫箟)銆傚皢璇ュ彉閲忚缃负绌哄瓧绗︿覆('')鍒欑鐢ㄥ仠姝㈠瓧杩囨护銆
娉閲婏細鏇存敼璇ュ彉閲忔垨鍋滄瀛楁枃浠剁殑鍐呭鍚庡繀椤婚噸寤FULLTEXT绱㈠紩銆傚簲浣跨敤REPAIR TABLE tbl_name QUICK銆
路 group_concat_max_len
鍏佽鐨GROUP_CONCAT()鍑芥暟缁撴灉鐨勬渶澶ч暱搴︺
路 have_archive
濡傛灉mysqld鏀寔ARCHIVE琛ㄥ垯涓YES锛屽惁鍒欎负NO銆
路 have_bdb
濡傛灉mysqld鏀寔BDB琛ㄥ垯涓YES銆傚鏋滀娇鐢--skip-bdb鍒欎负DISABLED銆
路 have_blackhole_engine
濡傛灉mysqld鏀寔BLACKHOLE琛ㄥ垯涓YES锛屽惁鍒欎负NO銆
路 have_compress
鏄惁zlib鍘嬬缉搴撻傚悎璇ユ湇鍔″櫒銆傚鏋滀笉閫傚悎锛屼笉鑳戒娇鐢COMPRESS()鍜UNCOMPRESS()鍑芥暟銆
路 have_crypt
鏄惁crypt()绯荤粺璋冪敤閫傚悎璇ユ湇鍔″櫒銆傚鏋滀笉閫傚悎锛屼笉鑳戒娇鐢CRYPT()鍑芥暟銆
路 have_csv
濡傛灉mysqld鏀寔ARCHIVE琛ㄥ垯涓YES锛屽惁鍒欎负NO銆
路 have_example_engine
濡傛灉mysqld鏀寔EXAMPLE琛ㄥ垯涓YES锛屽惁鍒欎负NO銆
have_federated_engine
濡傛灉mysqld鏀寔FEDERATED琛ㄥ垯涓YES锛屽惁鍒欎负NO銆
路 have_geometry
鏄惁鏈嶅姟鍣ㄦ敮鎸佺┖闂存暟鎹被鍨嬨
路 have_innodb
濡傛灉mysqld鏀寔InnoDB琛ㄥ垯涓YES銆傚鏋滀娇鐢--skip-innodb鍒欎负DISABLED銆
路 have_isam
鍦MySQL 5.1涓,鍙槸涓轰簡鍚戝悗鍏煎鏄剧ず璇ュ硷紝骞朵笖鎬绘槸NO锛屽洜涓轰笉鍐嶆敮鎸ISAM琛ㄣ
路 have_ndbcluster
濡傛灉mysqld鏀寔NDB CLUSTER琛ㄥ垯涓YES銆傚鏋滀娇鐢ㄤ簡--skip-ndbcluster鍒欎负DISABLED銆
路 have_partition_engine
濡傛灉mysqld鏀寔鍒嗗尯鍒欎负YES銆傚湪MySQL 5.1.1涓姞鍏ャ
路 have_openssl
濡傛灉mysqld鏀寔瀹㈡埛绔/鏈嶅姟鍣ㄥ崗璁殑SSL(鍔犲瘑)鍒欎负YES銆
路 have_query_cache
濡傛灉mysqld鏀寔鏌ヨ缂撳瓨鍒欎负YES銆
路 have_raid
濡傛灉mysqld鏀寔RAID閫夐」鍒欎负YES銆
路 have_rtree_keys
RTREE绱㈠紩鏄惁鍙敤銆(鐢ㄤ簬MyISAM琛ㄧ殑绌洪棿绱㈠紩锛銆
路 have_symlink
鏄惁鍚敤绗﹀彿閾炬帴鏀寔銆傚湪Unix涓渶瑕佺敤浜庢敮鎸DATA DIRECTORY鍜INDEX DIRECTORY琛ㄩ夐」銆
路 init_connect
鏈嶅姟鍣ㄤ负姣忎釜杩炴帴鐨勫鎴风鎵ц鐨勫瓧绗︿覆銆傚瓧绗︿覆鐢变竴涓垨澶氫釜SQL璇彞缁勬垚銆傝鎯虫寚瀹氬涓鍙ワ紝鐢ㄥ垎鍙烽棿闅斿紑銆備緥濡傦紝姣忎釜瀹㈡埛绔紑濮嬫椂榛樿鍚敤autocommit妯″紡銆傛病鏈夊叏灞鏈嶅姟鍣ㄥ彉閲忓彲浠ヨ瀹autocommit榛樿鎯呭喌涓嬪簲绂佺敤锛屼絾鍙互鐢init_connect鏉ヨ幏寰楃浉鍚岀殑鏁堟灉锛
SET GLOBAL init_connect='SET AUTOCOMMIT=0';
杩樺彲浠ュ湪鍛戒护琛屾垨閫夐」鏂囦欢涓缃鍙橀噺銆傝鎯充娇鐢ㄩ夐」鏂囦欢璁剧疆鍙橀噺锛屽簲鍖呮嫭涓嬭堪琛岋細
[mysqld]
init_connect='SET AUTOCOMMIT=0'
璇锋敞鎰init_connect鐨勫唴瀹瑰苟涓嶄负鎷ユ湁SUPER鏉冮檺鐨勭敤鎴锋墽琛岋紱瀹為檯鏄唴瀹硅缃敊璇(鍖呭惈閿欒鏌ヨ锛屼緥濡傝娉曢敊璇)锛岃繖鏍蜂娇鎵鏈夎繛鎺ュけ璐ャ備笉涓SUPER鐢ㄦ埛鎵ц锛屼娇SUPER鐢ㄦ埛鍙互鎵撳紑杩炴帴骞跺浐瀹init_connect銆
路 init_file
鍚姩鏈嶅姟鍣ㄦ椂鐢--init-file閫夐」鎸囧畾鐨勬枃浠跺悕銆傛枃浠朵腑鍖呭惈鏈嶅姟鍣ㄥ惎鍔ㄦ椂瑕佹墽琛岀殑SQL璇彞銆傛瘡涓鍙ュ繀椤诲湪鍚屼竴琛屼腑骞朵笖涓嶈兘鍖呮嫭娉ㄩ噴銆
路 init_slave
璇ュ彉閲忕被浼init_connect锛屼絾鏄瘡娆SQL绾跨▼鍚姩鏃朵粠鏈嶅姟鍣ㄥ簲鎵ц璇ュ瓧绗︿覆銆傝瀛楃涓茬殑鏍煎紡涓init_connect鍙橀噺鐩稿悓銆
路 innodb_xxx
InnoDB绯荤粺鍙橀噺鍒楀叆15.2.4鑺傦紝鈥淚nnoDB鍚姩閫夐」鈥銆
路 interactive_timeout
鏈嶅姟鍣ㄥ叧闂氦浜掑紡杩炴帴鍓嶇瓑寰呮椿鍔ㄧ殑绉掓暟銆備氦浜掑紡瀹㈡埛绔畾涔変负鍦mysql_real_connect()涓娇鐢CLIENT_INTERACTIVE閫夐」鐨勫鎴风銆傚張瑙wait_timeout銆
路 join_buffer_size
鐢ㄤ簬瀹屽叏鑱旀帴鐨勭紦鍐插尯鐨勫ぇ灏(褰撲笉浣跨敤绱㈠紩鐨勬椂鍊欎娇鐢ㄨ仈鎺ユ搷浣)銆備竴鑸儏鍐佃幏寰楀揩閫熻仈鎺ョ殑鏈濂芥柟娉曟槸娣诲姞绱㈠紩銆傚綋澧炲姞绱㈠紩鏃朵笉鍙兘閫氳繃澧炲姞join_buffer_size鍊兼潵鑾峰緱蹇熷畬鍏ㄨ仈鎺ャ傚皢涓轰袱涓〃涔嬮棿鐨勬瘡涓畬鍏ㄨ仈鎺ュ垎閰嶈仈鎺ョ紦鍐插尯銆傚浜庡涓〃涔嬮棿涓嶄娇鐢ㄧ储寮曠殑澶嶆潅鑱旀帴锛岄渶瑕佸鑱旀帴缂撳啿鍖恒
路 key_buffer_size
MyISAM琛ㄧ殑绱㈠紩鍧楀垎閰嶄簡缂撳啿鍖猴紝鐢辨墍鏈夌嚎绋嬪叡浜key_buffer_size鏄储寮曞潡缂撳啿鍖虹殑澶у皬銆傞敭鍊肩紦鍐插尯鍗充负閿肩紦瀛樸
key_buffer_size鐨勬渶澶у厑璁歌瀹氬间负4GB銆傛湁鏁堟渶澶у煎彲浠ユ洿灏忥紝鍙栧喅浜庡彲鐢ㄧ墿鐞RAM鍜屾搷浣滅郴缁熸垨纭欢骞冲彴寮哄姞鐨勬瘡涓繘绋嬬殑RAM闄愬埗銆
澧炲姞璇ュ硷紝杈惧埌浣犲彲浠ユ彁渚涚殑鏇村ソ鐨勭储寮曞鐞(鎵鏈夎鍜屽涓啓鎿嶄綔)銆傞氬父涓轰富瑕佽繍琛MySQL鐨勬満鍣ㄥ唴瀛樼殑25%銆備絾鏄紝濡傛灉浣犲皢璇ュ艰寰楄繃澶(渚嬪锛屽ぇ浜庢诲唴瀛樼殑50%)锛岀郴缁熷皢杞崲涓洪〉骞跺彉寰楁瀬鎱€MySQL渚濊禆鎿嶄綔绯荤粺鏉ユ墽琛屾暟鎹鍙栨椂鐨勬枃浠剁郴缁熺紦瀛橈紝鍥犳浣犲繀椤讳负鏂囦欢绯荤粺缂撳瓨鐣欎竴浜涚┖闂淬
鍚屾椂鍐欏琛屾椂瑕佹兂閫熷害鏇村揩锛屽簲浣跨敤LOCK TABLES銆傚弬瑙13.4.5鑺傦紝鈥淟OCK TABLES鍜孶NLOCK TABLES璇硶鈥銆
浣犲彲浠ラ氳繃鎵цSHOW STATUS璇彞骞舵鏌Key_read_requests銆Key_reads銆Key_write_requests鍜Key_writes鐘舵佸彉閲忔潵妫鏌ラ敭鍊肩紦鍐插尯鐨勬ц兘銆傚弬瑙13.5.4鑺傦紝鈥淪HOW璇硶鈥銆
Key_reads/Key_read_requests姣斾緥涓鑸簲灏忎簬0.01銆傚鏋滀綘浣跨敤鏇存柊鍜屽垹闄わ紝Key_writes/Key_write_requests姣斾緥閫氬父鎺ヨ繎1锛屼絾濡傛灉浣犳洿鏂版椂浼氬悓鏃跺奖鍝嶅埌澶氳鎴栧鏋滀綘姝d娇鐢DELAY_KEY_WRITE琛ㄩ夐」锛屽彲鑳藉皬寰楀銆
鐢key_buffer_size缁撳悎Key_blocks_unused鐘舵佸彉閲忓拰缂撳啿鍖哄潡澶у皬锛屽彲浠ョ‘瀹氫娇鐢ㄧ殑閿肩紦鍐插尯鐨勬瘮渚嬨備粠key_cache_block_size鏈嶅姟鍣ㄥ彉閲忓彲浠ヨ幏寰楃紦鍐插尯鍧楀ぇ灏忋備娇鐢ㄧ殑缂撳啿鍖虹殑姣斾緥涓猴細
1 - ((Key_blocks_unused * key_cache_block_size) / key_buffer_size)
璇ュ间负绾︽暟锛屽洜涓洪敭鍊肩紦鍐插尯鐨勯儴鍒嗙┖闂磋鍒嗛厤鐢ㄤ綔鍐呴儴绠$悊缁撴瀯銆
鍙互鍒涘缓澶氫釜MyISAM閿肩紦瀛樸4GB闄愬埗鍙互閫傚悎姣忎釜缂撳瓨锛岃屼笉鏄竴涓粍銆傚弬瑙7.4.6鑺傦紝鈥淢yISAM閿珮閫熺紦鍐测銆
路 key_cache_age_threshold
璇ュ兼帶鍒跺皢缂撳啿鍖轰粠閿肩紦瀛樼儹瀛愰摼(sub-chain)闄嶇骇鍒版俯瀛愰摼(sub-chain)銆傚鏋滃兼洿浣庯紝鍒欓檷绾ф洿蹇傛渶灏忓间负100銆 榛樿鍊兼槸300銆傚弬瑙7.4.6鑺傦紝鈥淢yISAM閿珮閫熺紦鍐测銆
路 key_cache_block_size
閿肩紦瀛樺唴鍧楃殑瀛楄妭澶у皬銆傞粯璁ゅ兼槸1024銆傚弬瑙7.4.6鑺傦紝鈥淢yISAM閿珮閫熺紦鍐测銆
路 key_cache_division_limit
閿肩紦瀛樼紦鍐插尯閾剧儹瀛愰摼鍜屾俯瀛愰摼鐨勫垝鍒嗙偣銆傝鍊间负缂撳啿鍖洪摼鐢ㄤ簬娓╁瓙閾剧殑鐧惧垎姣斻傚厑璁哥殑鍊肩殑鑼冨洿涓1鍒100銆 榛樿鍊兼槸100銆傚弬瑙7.4.6鑺傦紝鈥淢yISAM閿珮閫熺紦鍐测銆
路 language
閿欒娑堟伅鎵鐢ㄨ瑷銆
路 large_file_support
mysqld缂栬瘧鏃舵槸鍚︿娇鐢ㄤ簡澶ф枃浠舵敮鎸侀夐」銆
路 large_pages
璇存槑鏄惁鍚敤浜嗗ぇ椤甸潰鏀寔銆
路 license
鏈嶅姟鍣ㄧ殑璁稿彲绫诲瀷銆
路 local_infile
鏄惁LOCAL鏀寔LOAD DATA INFILE璇彞銆
路 locked_in_memory
鏄惁鐢鈥memlock灏mysqld閿佸湪鍐呭瓨涓
路 log
鏄惁鍚敤灏嗘墍鏈夋煡璇㈣褰曞埌甯歌鏌ヨ鏃ュ織涓傚弬瑙5.11.2鑺傦紝鈥滈氱敤鏌ヨ鏃ュ織鈥銆
路 log_bin
鏄惁鍚敤浜岃繘鍒舵棩蹇椼傚弬瑙5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆
路 log_bin_trust_routine_creators
鑻ュ惎鐢ㄤ簡浜岃繘鍒惰褰曪紝鍒欒鍙橀噺閫傜敤銆傚畠鎺у埗鏄惁鍙互淇′换淇濆瓨鐨勭▼搴忕殑浣滆呬笉浼氬垱寤哄悜浜岃繘鍒舵棩蹇楀啓鍏ヤ笉瀹夊叏浜嬩欢鐨勭▼搴忋傚鏋滆缃负0(榛樿鎯呭喌)锛屼笉鍏佽鐢ㄦ埛鍒涘缓鎴栦慨鏀逛繚瀛樼殑绋嬪簭锛岄櫎闈炰粬浠笉浠呮嫢鏈CREATE ROUTINE鎴ALTER ROUTINE鏉冮檺杩樻嫢鏈SUPER鏉冮檺銆
璁剧疆涓0杩樺己鍒堕檺鍒讹紝绋嬪簭蹇呴』鐢DETERMINISTIC 鐗瑰緛鎴栫敤READS SQL DATA鎴NO SQL鐗瑰緛澹版槑銆傚鏋滃彉閲忚缃负1,MySQL涓嶅淇濆瓨绋嬪簭鐨勫垱寤哄己鍔犻檺鍒躲
鍙傝20.4鑺傦紝鈥滃瓨鍌ㄥ瓙绋嬪簭鍜岃Е鍙戠▼搴忕殑浜岃繘鍒舵棩蹇楀姛鑳解銆
路 log_error
閿欒鏃ュ織鐨勪綅缃
路 log_slave_updates
鏄惁浠庢湇鍔″櫒浠庝富鏈嶅姟鍣ㄦ敹鍒扮殑鏇存柊搴旇鍏ヤ粠鏈嶅姟鍣ㄨ嚜宸辩殑浜岃繘鍒舵棩蹇椼傝鎯崇敓鏁堬紝蹇呴』鍚敤浠庢湇鍔″櫒鐨勪簩杩涘埗璁板綍銆傚弬瑙6.8鑺傦紝鈥滃鍒跺惎鍔ㄩ夐」鈥銆
路 log_slow_queries
鏄惁璁板綍鎱㈡煡璇€傜敤long_query_time鍙橀噺鐨勫兼潵纭畾鈥滄參鏌ヨ鈥濄傚弬瑙5.11.4鑺傦紝鈥滄參閫熸煡璇㈡棩蹇椻銆
路 log_warnings
鏄惁浜х敓鍏跺畠璀﹀憡娑堟伅銆傞粯璁ゆ儏鍐典笅鍚敤銆傛斁寮冪殑杩炴帴涓嶈鍏ラ敊璇棩蹇楋紝闄ら潪鍊煎ぇ浜1銆
路 long_query_time
濡傛灉鏌ヨ鏃堕棿瓒呰繃璇ュ硷紝鍒欏鍔Slow_queries鐘舵佸彉閲忋傚鏋滀綘姝d娇鐢--log-slow-queries閫夐」锛屽垯鏌ヨ璁板叆鎱㈡煡璇㈡棩蹇楁枃浠躲傜敤瀹為檯鏃堕棿娴嬮噺璇ュ硷紝鑰屼笉鏄CPU鏃堕棿锛屽洜姝や綆浜庤交璐熻浇绯荤粺闃堝肩殑鏌ヨ鍙兘瓒呰繃閲嶈礋杞界郴缁熺殑闃堝笺傚弬瑙5.11.4鑺傦紝鈥滄參閫熸煡璇㈡棩蹇椻銆
路 low_priority_updates
濡傛灉璁剧疆涓1锛屾墍鏈INSERT銆UPDATE銆DELETE鍜LOCK TABLE WRITE璇彞灏嗙瓑寰呯洿鍒板彈褰卞搷鐨勮〃娌℃湁鎸傝捣鐨SELECT鎴LOCK TABLE READ銆傝鍙橀噺浠ュ墠鍙仛sql_low_priority_updates銆
路 lower_case_file_system
璇ュ彉閲忚鏄庢槸鍚︽暟鎹洰褰曟墍鍦ㄧ殑鏂囦欢绯荤粺瀵规枃浠跺悕鐨勫ぇ灏忓啓鏁忔劅銆ON璇存槑瀵规枃浠跺悕鐨勫ぇ灏忓啓涓嶆晱鎰燂紝OFF琛ㄧず鏁忔劅銆
路 lower_case_table_names
濡傛灉璁剧疆涓1,琛ㄥ悕鐢ㄥ皬鍐欎繚瀛樺埌纭洏涓婏紝骞朵笖琛ㄥ悕姣旇緝鏃朵笉瀵瑰ぇ灏忓啓鏁忔劅銆傚鏋滆缃负2锛屾寜鐓ф寚瀹氱殑淇濆瓨琛ㄥ悕锛屼絾鎸夌収灏忓啓鏉ユ瘮杈冦傝閫夐」杩橀傚悎鏁版嵁搴撳悕鍜岃〃鐨勫埆鍚嶃傚弬瑙9.2.2鑺傦紝鈥滆瘑鍒澶у皬鍐欐晱鎰熸р銆
濡傛灉浣犳浣跨敤InnoDB琛紝浣犲簲鍦ㄦ墍鏈夊钩鍙颁笂灏嗚鍙橀噺璁剧疆涓1锛屽己鍒跺皢鍚嶅瓧杞崲涓哄皬鍐欍
濡傛灉杩愯MySQL鐨勭郴缁熷鏂囦欢鍚嶇殑澶у皬鍐欎笉鏁忔劅(渚嬪Windows鎴Mac OS X)锛屼綘涓嶅簲灏嗚鍙橀噺璁剧疆涓0銆傚鏋滃惎鍔ㄦ椂娌℃湁璁剧疆璇ュ彉閲忥紝骞朵笖鏁版嵁鐩綍鎵鍦ㄦ枃浠剁郴缁熷鏂囦欢鍚嶇殑澶у皬鍐欎笉鏁忔劅锛MySQL鑷姩灏lower_case_table_names璁剧疆涓2銆
路 max_allowed_packet
鍖呮垨浠讳綍鐢熸垚鐨/涓棿瀛楃涓茬殑鏈澶уぇ灏忋
鍖呮秷鎭紦鍐插尯鍒濆鍖栦负net_buffer_length瀛楄妭锛屼絾闇瑕佹椂鍙互澧為暱鍒max_allowed_packet瀛楄妭銆傝鍊奸粯璁ゅ緢灏忥紝浠ユ崟鑾峰ぇ鐨(鍙兘鏄敊璇殑)鏁版嵁鍖呫
濡傛灉浣犱娇鐢ㄥぇ鐨BLOB 鍒楁垨闀垮瓧绗︿覆锛屼綘蹇呴』澧炲姞璇ュ笺傚簲鍚屼綘鎯宠浣跨敤鐨勬渶澶х殑BLOB涓鏍峰ぇ銆max_allowed_packet鐨勫崗璁檺鍒朵负1GB銆
路 max_binlog_cache_size
濡傛灉澶氳鍙ヤ簨鍔¢渶瑕佹洿澶х殑鍐呭瓨锛屼綘浼氬緱鍒伴敊璇Multi-statement transaction required more than 'max_binlog_cache_size' bytes of storage銆
路 max_binlog_size
濡傛灉浜岃繘鍒舵棩蹇楀啓鍏ョ殑鍐呭瓒呭嚭缁欏畾鍊硷紝鏃ュ織灏变細鍙戠敓婊氬姩銆備綘涓嶈兘灏嗚鍙橀噺璁剧疆涓哄ぇ浜1GB鎴栧皬浜4096瀛楄妭銆 榛樿鍊兼槸1GB銆
璇锋敞鎰忓鏋滀綘姝d娇鐢ㄤ簨鍔★細浜嬪姟浠ヤ竴涓潡鍐欏叆浜岃繘鍒舵棩蹇楋紝鍥犳涓嶄笉鑳借鍑犱釜浜岃繘鍒舵棩蹇楁媶鍒嗐傚洜姝わ紝濡傛灉浣犳湁澶х殑浜嬪姟锛屼簩杩涘埗鏃ュ織鍙兘浼氬ぇ浜max_binlog_size銆
濡傛灉max_relay_log_size涓0, max_binlog_size鐨勫间篃閫傜敤浜庝腑缁ф棩蹇銆
路 max_connect_errors
濡傛灉涓柇鐨勪笌涓绘満鐨勮繛鎺ヨ秴杩囪鏁扮洰锛岃涓绘満鍒欓樆濉炲悗闈㈢殑杩炴帴銆備綘鍙互鐢 FLUSH HOSTS璇彞瑙i攣閿佸畾鐨勪富鏈恒
路 max_connections
鍏佽鐨勫苟琛屽鎴风杩炴帴鏁扮洰銆傚澶ц鍊煎垯澧炲姞mysqld 闇瑕佺殑鏂囦欢鎻忚堪绗︾殑鏁伴噺銆傚叧浜庢枃浠舵弿杩扮闄愬埗鐨勬敞閲婂弬瑙7.4.9鑺傦紝鈥淢ySQL濡備綍鎵撳紑鍜屽叧闂〃鈥銆傝繕鍙弬瑙A.2.6鑺傦紝鈥滆繛鎺ユ暟杩囧鈥銆
路 max_delayed_threads
涓嶈鍚姩澶т簬璇ユ暟鐩殑绾跨▼鏉ュ鐞INSERT DELAYED璇彞銆傚鏋滄墍鏈INSERT DELAYED绾跨▼宸茬粡鍦ㄤ娇鐢紝浣犳兂鍦ㄦ柊琛ㄤ腑鎻掑叆鏁版嵁锛岃 鎻掑叆鏃跺ソ鍍忔湭鎸囧畾DELAYED灞炴с傚鏋滀綘灏嗚鍊艰缃负0,MySQL涓嶄細鍒涘缓绾跨▼鏉ュ鐞DELAYED琛岋紱鍏剁粨鏋滄槸瀹屽叏绂佺敤浜DELAYED銆
路 max_error_count
淇濆瓨鐢SHOW ERRORS鎴SHOW WARNINGS鏄剧ず鐨勯敊璇佽鍛婂拰娉ㄨВ鐨勬渶澶ф暟鐩
路 max_heap_table_size
璇ュ彉閲忚缃MEMORY (HEAP)琛ㄥ彲浠ュ闀垮埌鐨勬渶澶х┖闂村ぇ灏忋傝鍙橀噺鐢ㄦ潵璁$畻MEMORY琛ㄧ殑MAX_ROWS鍊笺傚湪宸叉湁鐨MEMORY琛ㄤ笂璁剧疆璇ュ彉閲忔病鏈夋晥鏋滐紝闄ら潪鐢CREATE TABLE鎴TRUNCATE TABLE绛夎鍙ラ噸鏂板垱寤鸿〃銆
路 max_insert_delayed_threads
璇ュ彉閲忎负max_delayed_threads鐨勫悓涔夎瘝銆
路 max_join_size
涓嶅厑璁稿彲鑳介渶瑕佹鏌ュ浜max_join_size琛(涓哄崟涓〃璇彞)鎴栬缁勫悎(涓哄涓〃璇彞)鎴栧彲鑳芥墽琛屽ぇ浜max_join_size娆$‖鐩樻煡璇㈢殑SELECT璇彞銆傞氳繃璁剧疆璇ュ硷紝浣犲彲浠ユ崟鑾烽敭浣跨敤涓嶆纭苟鍙兘鑺卞緢闀挎椂闂寸殑SELECT璇彞銆傚鏋滅敤鎴锋兂瑕佹墽琛屾病鏈WHERE瀛愬彞鐨勮姳杈冮暱鏃堕棿鎴栬繑鍥炴暟鐧句竾琛岀殑鑱旀帴锛屽垯璁剧疆瀹冦
灏嗚鍙橀噺璁剧疆涓DEFAULT涔嬪鐨勫硷紝灏SQL_BIG_SELECTS鐨勫奸噸璁句负0銆濡傛灉浣犻噸鏂拌缃SQL_BIG_SELECTS鍊硷紝max_join_size鍙橀噺琚拷鐣ャ
濡傛灉鏌ヨ缁撴灉浣嶄簬鏌ヨ缂撳瓨涓紝鍒欎笉妫鏌ョ粨鏋滃ぇ灏忥紝鍥犱负鍓嶉潰宸茬粡璁$畻浜嗙粨鏋滐紝涓嶄細瑕佹眰鏈嶅姟鍣ㄥ皢瀹冨彂閫佺粰瀹㈡埛绔
璇ュ彉閲忎互鍓嶅彨鍋sql_max_join_size銆
路 max_length_for_sort_data
纭畾浣跨敤鐨filesort绠楁硶鐨勭储寮曞煎ぇ灏忕殑闄愬笺傚弬瑙7.2.12鑺傦紝鈥淢ySQL濡備綍浼樺寲ORDER BY鈥銆
路 max_relay_log_size
濡傛灉澶嶅埗浠庢湇鍔″櫒鍐欏叆涓户鏃ュ織鏃惰秴鍑虹粰瀹氬硷紝鍒欐粴鍔ㄤ腑缁ф棩蹇椼傞氳繃璇ュ彉閲忎綘鍙互瀵逛腑缁ф棩蹇楀拰浜岃繘鍒舵棩蹇楄缃笉鍚岀殑闄愬埗銆備絾鏄紝灏嗚鍙橀噺璁剧疆涓0锛MySQL鍙互瀵逛簩杩涘埗鏃ュ織鍜屼腑缁ф棩蹇椾娇鐢max_binlog_size銆max_relay_log_size蹇呴』璁剧疆鍦4096瀛楄妭鍜1GB(鍖呮嫭)涔嬮棿锛屾垨涓0銆 榛樿鍊兼槸0銆傚弬瑙6.3鑺傦紝鈥滃鍒跺疄鏂界粏鑺傗銆
路 max_seeks_for_key
闄愬埗鏍规嵁閿煎鎵捐鏃剁殑鏈澶ф悳绱㈡暟銆MySQL浼樺寲鍣ㄥ亣瀹氬綋鐢ㄦ壂鎻忛敭鍦ㄨ〃鍐呮悳绱㈠尮閰嶇殑琛屾椂锛屼笉闇瑕佽秴杩囪鏁伴噺鐨勯敭鍊兼悳绱紝鑰屼笉绠¢敭鐨勫疄闄呭熀鏁版槸浠涔(鍙傝13.5.4.11鑺傦紝鈥淪HOW INDEX璇硶鈥)銆傚皢璇ュ艰缃负杈冧綆鐨勫(100?)锛屼綘鍙互寮哄埗MySQL閫夋嫨閿艰屼笉閫夋嫨琛ㄦ壂鎻忋
路 max_sort_length
褰撴帓搴BLOB鎴TEXT鍊兼椂浣跨敤鐨勫瓧鑺傛暟銆傚彧浣跨敤姣忎釜鍊肩殑鍓max_sort_length瀛楄妭锛涘叾瀹冪殑琚拷鐣ャ
路 max_tmp_tables
瀹㈡埛绔彲浠ュ悓鏃舵墦寮鐨勪复鏃惰〃鐨勬渶澶ф暟銆(浣嗚閫夐」杩樻湭鐢熸晥锛銆
路 max_user_connections
浠讳綍缁欏畾鐨MySQL璐︽埛鍏佽鐨勬渶澶у悓鏃惰繛鎺ユ暟銆0鍊艰〃绀衡滄病鏈闄愬埗鈥濄
璇ュ彉閲忓叿鏈夊叏灞鑼冨洿鍜(鍙)浼氳瘽鑼冨洿銆備細璇濆彉閲忕殑鐨勫间笌鍏ㄥ眬鍙橀噺鐨勫肩浉鍚岋紝闄ら潪褰撳墠璐︽埛鍏锋湁闈為浂MAX_USER_CONNECTIONS璧勬簮闄愬埗銆傚湪杩欑鎯呭喌涓嬶紝浼氳瘽鍊煎弽搴斾簡璐︽埛闄愬埗銆
路 max_write_lock_count
瓒呰繃鍐欓攣瀹氶檺鍒跺悗锛屽厑璁搁儴鍒嗚閿佸畾銆
路 myisam_data_pointer_size
榛樿鎸囬拡澶у皬锛屽崟浣嶆槸瀛楄妭锛屽綋鏈寚瀹MAX_ROWS閫夐」鏃讹紝CREATE TABLE浣跨敤璇ュ彉閲忓垱寤MyISAM琛ㄣ傝鍙橀噺涓嶈兘灏忎簬2鎴栧ぇ浜7銆 榛樿鍊兼槸6銆傚弬瑙A.2.11鑺傦紝鈥滆〃宸叉弧鈥銆
路 (DEPRECATED) myisam_max_extra_sort_file_size
娉閲婏細MySQL 5.1涓嶆敮鎸佽鍙橀噺銆傝缁嗕俊鎭弬瑙MySQL 5.0 鍙傝冩墜鍐銆
路 myisam_max_sort_file_size
閲嶅缓MyISAM绱㈠紩(鍦REPAIR TABLE銆ALTER TABLE鎴LOAD DATA INFILE杩囩▼涓)鏃讹紝鍏佽MySQL浣跨敤鐨勪复鏃舵枃浠剁殑鏈澶х┖闂村ぇ灏忋傚鏋滄枃浠剁殑澶у皬瓒呰繃璇ュ硷紝鍒欎娇鐢ㄩ敭鍊肩紦瀛樺垱寤虹储寮曪紝瑕佹參寰楀銆傝鍊肩殑鍗曚綅涓哄瓧鑺傘
路 myisam_recover_options
--myisam-recover閫夐」鐨勫笺
路 myisam_repair_threads
濡傛灉璇ュ煎ぇ浜1锛屽湪Repair by sorting杩囩▼涓苟琛屽垱寤MyISAM琛ㄧ储寮(姣忎釜绱㈠紩鍦ㄨ嚜宸辩殑绾跨▼鍐)銆 榛樿鍊兼槸1銆娉閲婏細澶氱嚎绋嬬淮鎶や粛鐒舵槸alpha 缂栫爜銆
路 myisam_sort_buffer_size
褰撳湪REPAIR TABLE鎴栫敤CREATE INDEX鍒涘缓绱㈠紩鎴ALTER TABLE杩囩▼涓帓搴 MyISAM绱㈠紩鍒嗛厤鐨勭紦鍐插尯銆
路 myisam_stats_method
褰撲负MyISAM琛ㄦ悳闆嗗叧浜庣储寮曞煎垎鍙戠殑缁熻淇℃伅鏃舵湇鍔″櫒濡備綍澶勭悊NULL鍊笺傝鍙橀噺鏈変袱涓彲鑳界殑鍊硷紝nulls_equal鍜nulls_unequal銆傚浜nulls_equal锛岃涓烘墍鏈NULL绱㈠紩鍊兼椂鐩哥瓑鐨勶紝骞跺舰鎴愪竴涓暟鍊肩粍锛屽叾绌洪棿澶у皬绛変簬NULL鍊肩殑鏁般傚浜nulls_unequal锛NULL鍊艰涓烘槸涓嶇浉绛夌殑锛屾瘡涓NULL褰㈡垚涓涓暟鍊肩粍锛屽ぇ灏忎负1銆
鏂规硶鐢ㄤ簬鐢熸垚琛ㄧ粺璁′俊鎭紝褰卞搷浼樺寲鍣ㄥ浣曢夋嫨绱㈠紩鏉ユ墽琛屾煡璇紝璇︾粏鎻忚堪瑙7.4.7鑺傦紝鈥淢yISAM绱㈠紩缁熻闆嗗悎鈥銆
路 multi_read_range
鎸囧畾鑼冨洿閫夋嫨杩囩▼涓彂閫佸埌瀛樺偍寮曟搸鐨勮寖鍥寸殑鏈澶у笺傞粯璁ゅ兼槸256銆傚悜寮曟搸鍙戦佸涓寖鍥村彲浠ュぇ澶ф敼杩涙煇浜涢夋嫨鐨勬ц兘锛岀壒鍒槸瀵NDBCLUSTER銆傝寮曟搸闇瑕佸悜鎵鏈夎妭鐐瑰彂閫佽寖鍥磋姹傦紝鍚屾椂鍙戦佽澶氳姹傚彲浠ュぇ澶ч檷浣庨氫俊鎴愭湰銆
路 named_pipe
(鍙傜敤Windows)璇存槑鏈嶅姟鍣ㄦ槸鍚︽敮鎸佸懡鍚嶇閬撹繛鎺ャ
路 net_buffer_length
鍦ㄦ煡璇箣闂村皢閫氫俊缂撳啿鍖洪噸璁句负璇ュ笺備竴鑸儏鍐典笉搴旀敼鍙橈紝浣嗗鏋滃唴瀛樺緢灏忥紝鍙互灏嗗畠璁剧疆涓烘湡鏈涚殑瀹㈡埛绔彂閫佺殑SQL璇彞鐨勯暱搴︺傚鏋滆鍙ヨ秴鍑鸿闀垮害锛岀紦鍐插尯鑷姩鎵╁ぇ锛岀洿鍒max_allowed_packet瀛楄妭銆
路 net_read_timeout
涓柇璇诲墠绛夊緟杩炴帴鐨勫叾瀹冩暟鎹殑绉掓暟銆傚綋鏈嶅姟鍣ㄤ粠瀹㈡埛绔鏁版椂锛net_read_timeout鎸囨帶鍒朵綍鏃朵腑鏂殑瓒呮椂鍊笺傚綋鏈嶅姟鍣ㄥ悜瀹㈡埛绔啓鏃讹紝net_write_timeout鎸囨帶鍒朵綍鏃朵腑鏂殑瓒呮椂鍊笺傚張瑙slave_net_timeout銆
路 net_retry_count
濡傛灉鏌愪釜閫氫俊绔彛鐨勮鎿嶄綔涓柇浜嗭紝鍦ㄦ斁寮冨墠閲嶈瘯澶氭銆傚湪FreeBSD涓鍊煎簲璁惧緱寰堥珮锛屽洜涓哄唴閮ㄤ腑鏂皢鍙戦佽嚦鎵鏈夌嚎绋嬨
路 net_write_timeout
涓柇鍐欎箣鍓嶇瓑寰呭潡鍐欏叆杩炴帴鐨勭鏁般傚張瑙net_read_timeout銆
路 new
鍦MySQL 4.0涓娇鐢ㄨ鍙橀噺鏉ユ墦寮4.1涓殑涓浜涜涓猴紝骞剁敤浜庡悜鍚庡吋瀹规с傚湪MySQL 5.1涓,瀹冪殑鍊间竴鐩存槸OFF.
路 old_passwords
鏄惁鏈嶅姟鍣ㄥ簲涓MySQL鐢ㄦ埛璐︽埛浣跨敤pre-4.1-style瀵嗙爜銆傚弬瑙A.2.3鑺傦紝鈥滃鎴风涓嶆敮鎸侀壌瀹氬崗璁銆
路 one_shot
杩欎笉鏄竴涓彉閲忥紝浣嗗綋璁剧疆鍙橀噺鏄彲浠ヤ娇鐢ㄥ畠銆傚叾鎻忚堪瑙13.5.3鑺傦紝鈥淪ET璇硶鈥銆
路 one_shot
杩欎笉鏄竴涓彉閲忥紝浣嗗綋璁剧疆鍙橀噺鏄彲浠ヤ娇鐢ㄥ畠銆傚叾鎻忚堪瑙13.5.3鑺傦紝鈥淪ET璇硶鈥銆
路 open_files_limit
鎿嶄綔绯荤粺鍏佽mysqld鎵撳紑鐨勬枃浠剁殑鏁伴噺銆傝繖鏄郴缁熷厑璁哥殑瀹為檯鍊硷紝鍙兘涓庝綘鍦ㄥ惎鍔ㄩ夐」涓祴缁mysqld鐨勫间笉鍚屻傝嫢鍦ㄧ郴缁熶腑MySQL涓嶈兘鏇存敼鎵撳紑鐨勬枃浠剁殑鏁伴噺锛屽垯璇ュ间负0銆
路 optimizer_prune_level
鍦ㄦ煡璇紭鍖栦粠浼樺寲鍣ㄦ悳绱㈢┖闂磋鍑忎綆甯屾湜灞閮ㄨ鍒掍腑浣跨敤鐨勬帶鍒舵柟娉曘0鍊肩鐢ㄨ鏂规硶锛屼互渚夸紭鍖栧櫒杩涜绌蜂妇鎼滅储銆傚间负1浣夸紭鍖栧櫒鏍规嵁涓棿鏂规涓緱鍑虹殑琛屾暟鏉ヨ鍑忔柟妗堛
路 optimizer_search_depth
鏌ヨ浼樺寲鍣ㄨ繘琛岀殑鎼滅储鐨勬渶澶ф繁搴︺傚鏋滃煎ぇ浜庢煡璇腑鐨勫叧绯绘暟鍒欐煡璇㈡柟妗堟瘮杈冧匠锛屼絾鐢熸垚鏌ヨ鎵ц鏂规闇瑕佺殑鏃堕棿鏇撮暱銆傚煎ぇ浜庢煡璇腑鐨勫叧绯绘暟鍒欒繑鍥炵殑鎵ц鏂规鏇村揩锛屼絾鏂规杩滄病鏈変紭鍖栥傚鏋滆缃负0, 绯荤粺鑷姩閫夋嫨鍚堢悊鐨勫笺傚鏋滆缃负鏌ヨ涓娇鐢ㄧ殑琛ㄧ殑鏈澶ф暟鍔2,浼樺寲鍣ㄨ浆鎹负MySQL 5.0.0(鍜屼互鍓嶇殑鐗堟湰)涓娇鐢ㄧ殑绠楁硶骞舵悳绱€
路 pid_file
杩涚▼ID (PID)鏂囦欢鐨勮矾寰勫悕銆傚彲浠ョ敤--pid-file閫夐」璁剧疆璇ュ彉閲忋
路 plugin_dir
鎻掍欢鐩綍鐨勮矾寰勩傚湪MySQL 5.1.2涓姞鍏ヤ簡璇ュ彉閲忋
路 port
鏈嶅姟鍣ㄥ抚鍚TCP/IP杩炴帴鎵鐢ㄧ鍙c傚彲浠ョ敤--port閫夐」璁剧疆璇ュ彉閲忋
路 preload_buffer_size
閲嶈浇绱㈠紩鏃跺垎閰嶇殑缂撳啿鍖哄ぇ灏忋
路 protocol_version
MySQL鏈嶅姟鍣ㄤ娇鐢ㄧ殑瀹㈡埛绔/鏈嶅姟鍣ㄥ崗璁殑鐗堟湰銆
路 query_alloc_block_size
涓烘煡璇㈠垎鏋愬拰鎵ц杩囩▼涓垱寤虹殑瀵硅薄鍒嗛厤鐨勫唴瀛樺潡澶у皬銆傚鏋滃唴瀛樺垎娈佃繃绋嬩腑閬囧埌闂锛屽皢璇ュ彉閲忓鍔犱竴浣嶄細鏈夊府鍔┿
路 query_cache_limit
涓嶈缂撳瓨澶т簬璇ュ肩殑缁撴灉銆傞粯璁ゅ兼槸1048576(1MB)銆
路 query_cache_min_res_unit
鏌ヨ缂撳瓨鍒嗛厤鐨勬渶灏忓潡鐨勫ぇ灏(瀛楄妭)銆 榛樿鍊兼槸4096(4KB)銆傚叧浜庤鍙橀噺鐨勮皟鑺備俊鎭弬瑙5.13.3鑺傦紝鈥滄煡璇㈤珮閫熺紦鍐查厤缃銆
路 query_cache_size
涓虹紦瀛樻煡璇㈢粨鏋滃垎閰嶇殑鍐呭瓨鐨勬暟閲忋傞粯璁ゅ兼槸0锛屽嵆绂佺敤鏌ヨ缂撳瓨銆傝娉ㄦ剰鍗充娇query_cache_type璁剧疆涓0涔熷皢鍒嗛厤姝ゆ暟閲忕殑鍐呭瓨銆傝缁嗕俊鎭弬瑙5.13.3鑺傦紝鈥滄煡璇㈤珮閫熺紦鍐查厤缃銆
路 query_cache_type
璁剧疆鏌ヨ缂撳瓨绫诲瀷銆傝缃GLOBAL鍊煎彲浠ヨ缃悗闈㈢殑鎵鏈夊鎴风杩炴帴鐨勭被鍨嬨傚鎴风鍙互璁剧疆SESSION鍊间互褰卞搷浠栦滑鑷繁瀵规煡璇㈢紦瀛樼殑浣跨敤銆備笅闈㈢殑琛ㄦ樉绀轰簡鍙兘鐨勫硷細
閫夐」 |
鎻忚堪 |
0鎴OFF |
涓嶈缂撳瓨鎴栨煡璇㈢粨鏋溿傝娉ㄦ剰杩欐牱涓嶄細鍙栨秷鍒嗛厤鐨勬煡璇㈢紦瀛樺尯銆傝鎯冲彇娑堬紝浣犲簲灏query_cache_size璁剧疆涓0銆 |
1鎴ON |
缂撳瓨闄や簡浠SELECT SQL_NO_CACHE寮澶寸殑鎵鏈夋煡璇㈢粨鏋溿 |
2鎴DEMAND |
鍙紦瀛樹互SELECT SQL_NO_CACHE寮澶寸殑鏌ヨ缁撴灉銆 |
璇ュ彉閲忛粯璁よ涓ON銆
路 query_cache_wlock_invalidate
涓鑸儏鍐碉紝褰撳鎴风瀵MyISAM琛ㄨ繘琛WRITE閿佸畾鏃讹紝濡傛灉鏌ヨ缁撴灉浣嶄簬鏌ヨ缂撳瓨涓紝鍒欏叾瀹冨鎴风鏈閿佸畾锛屽彲浠ュ璇ヨ〃杩涜鏌ヨ銆傚皢璇ュ彉閲忚缃负1锛屽垯鍙互瀵硅〃杩涜WRITE閿佸畾锛屼娇鏌ヨ缂撳瓨鍐呮墍鏈夊璇ヨ〃杩涜鐨勬煡璇㈠彉寰楅潪娉曘傝繖鏍峰綋閿佸畾鐢熸晥鏃讹紝鍙互寮哄埗鍏跺畠璇曞浘璁块棶琛ㄧ殑瀹㈡埛绔潵绛夊緟銆
路 query_prealloc_size
鐢ㄤ簬鏌ヨ鍒嗘瀽鍜屾墽琛岀殑鍥哄畾缂撳啿鍖虹殑澶у皬銆傚湪鏌ヨ涔嬮棿璇ョ紦鍐插尯涓嶉噴鏀俱傚鏋滀綘鎵ц澶嶆潅鏌ヨ锛屽垎閰嶆洿澶х殑query_prealloc_size鍊煎彲浠ュ府鍔╂彁楂樻ц兘锛屽洜涓哄畠鍙互闄嶄綆鏌ヨ杩囩▼涓湇鍔″櫒鍒嗛厤鍐呭瓨鐨勯渶姹傘
路 range_alloc_block_size
鑼冨洿浼樺寲鏃跺垎閰嶇殑鍧楃殑澶у皬銆
路 read_buffer_size
姣忎釜绾跨▼杩炵画鎵弿鏃朵负鎵弿鐨勬瘡涓〃鍒嗛厤鐨勭紦鍐插尯鐨勫ぇ灏(瀛楄妭)銆傚鏋滆繘琛屽娆¤繛缁壂鎻忥紝鍙兘闇瑕佸鍔犺鍊硷紝 榛樿鍊间负131072銆
路 read_only
褰撳彉閲忓澶嶅埗浠庢湇鍔″櫒璁剧疆涓ON鏃讹紝浠庢湇鍔″櫒涓嶅厑璁告洿鏂帮紝闄ら潪閫氳繃浠庢湇鍔″櫒鐨勭嚎绋嬫垨鐢ㄦ埛鎷ユ湁SUPER鏉冮檺銆傚彲浠ョ‘淇濅粠鏈嶅姟鍣ㄤ笉鎺ュ彈瀹㈡埛绔殑鏇存柊鍛戒护銆
路 relay_log_purge
褰撲笉鍐嶉渶瑕佷腑缁ф棩蹇楁椂绂佺敤鎴栧惎鐢ㄨ嚜鍔ㄦ竻绌轰腑缁ф棩蹇椼傞粯璁ゅ兼槸1(鍚敤)銆
路 read_rnd_buffer_size
褰撴帓搴忓悗鎸夋帓搴忓悗鐨勯『搴忚鍙栬鏃讹紝鍒欓氳繃璇ョ紦鍐插尯璇诲彇琛岋紝閬垮厤鎼滅储纭洏銆傚皢璇ュ彉閲忚缃负杈冨ぇ鐨勫煎彲浠ュぇ澶ф敼杩ORDER BY鐨勬ц兘銆備絾鏄紝杩欐槸涓烘瘡涓鎴风鍒嗛厤鐨勭紦鍐插尯锛屽洜姝や綘涓嶅簲灏嗗叏灞鍙橀噺璁剧疆涓鸿緝澶х殑鍊笺傜浉鍙嶏紝鍙负闇瑕佽繍琛屽ぇ鏌ヨ鐨勫鎴风鏇存敼浼氳瘽鍙橀噺銆
路 secure_auth
濡傛灉鐢--secure-auth閫夐」鍚姩浜MySQL鏈嶅姟鍣紝瀹冨皢闃诲鏈夋棫鏍煎紡(4.1涔嬪墠)瀵嗙爜鐨勬墍鏈夎处鎴锋墍鍙戣捣鐨勮繛鎺ャ傚湪杩欑鎯呭喌涓嬶紝璇ュ彉閲忕殑鍊间负ON锛屽惁鍒欎负OFF銆
濡傛灉浣犳兂瑕侀槻姝娇鐢ㄦ棫鏍煎紡鐨勫瘑鐮(鑷翠娇缃戠粶閫氫俊涓嶅畨鍏)锛屼綘搴斿惎鐢ㄨ閫夐」銆
濡傛灉鍚敤璇ラ夐」骞朵笖鎺堟潈琛ㄤ负pre-4.1鏍煎紡锛屾湇鍔″櫒鍚姩澶辫触骞朵笖浼氬嚭鐜伴敊璇傚弬瑙A.2.3鑺傦紝鈥滃鎴风涓嶆敮鎸侀壌瀹氬崗璁銆
褰撶敤浜庡鎴风閫夐」鏃讹紝濡傛灉鏈嶅姟鍣ㄩ渶瑕佽瀹㈡埛绔处鎴风殑鏃ф牸寮忕殑瀵嗙爜锛屽垯瀹㈡埛绔嫆缁濊繛鎺ヨ鏈嶅姟鍣ㄣ
路 server_id
--server-id閫夐」鐨勫笺傜敤浜庝富澶嶅埗鏈嶅姟鍣ㄥ拰浠庡鍒舵湇鍔″櫒銆
路 shared_memory
(鍙敤浜Windows)鏈嶅姟鍣ㄦ槸鍚﹀厑璁稿叡浜唴瀛樿繛鎺ャ
路 shared_memory_base_name
(鍙敤浜Windows)璇存槑鏈嶅姟鍣ㄦ槸鍚﹀厑璁稿叡浜唴瀛樿繛鎺ワ紝骞朵负鍏变韩鍐呭瓨璁剧疆璇嗗埆绗︺傚綋鍦ㄥ崟鍙版満鍣ㄤ笂杩愯澶氫釜MySQL瀹炰緥鏃跺緢鏈夌敤銆
路 skip_external_locking
濡傛灉mysqld浣跨敤澶栭儴閿佸畾锛岃鍊间负OFF銆
路 skip_networking
濡傛灉鏈嶅姟鍣ㄥ彧鍏佽鏈湴(闈TCP/IP)杩炴帴锛岃鍊间负ON銆傚湪Unix涓紝鏈湴杩炴帴浣跨敤Unix濂楁帴瀛楁枃浠躲傚湪Windows涓紝鏈湴杩炴帴浣跨敤鍛藉悕绠¢亾鎴栧叡浜唴瀛樸傚湪NetWare涓紝鍙敮鎸TCP/IP杩炴帴锛屽洜姝や笉瑕佸皢璇ュ彉閲忚缃负ON銆
路 skip_show_database
闃叉涓嶅叿鏈SHOW DATABASES鏉冮檺鐨勪汉浠娇鐢SHOW DATABASES璇彞銆傚鏋滀綘鎷呭績鐢ㄦ埛鑳藉鐪嬭灞炰簬鍏跺畠鐢ㄦ埛鐨勬暟鎹簱锛岃繖鏍疯缃彲浠ユ彁楂樺畨鍏ㄦс傚叾鏁堟灉鍙栧喅浜SHOW DATABASES鏉冮檺锛氬鏋滃彉閲忓间负ON锛屽彧鍏佽鍏锋湁SHOW DATABASES鏉冮檺鐨勪汉浠娇鐢SHOW DATABASES 璇彞锛屽苟涓旇璇彞灏嗘樉绀烘墍鏈夋暟鎹簱鍚嶃傚鏋滃间负OFF锛屽厑璁告墍鏈夌敤鎴锋墽琛SHOW DATABASES锛屼絾鍙樉绀虹敤鎴峰叿鏈SHOW DATABASES鎴栧叾瀹冩潈闄愮殑鏁版嵁搴撶殑鍚嶇О銆
路 slave_compressed_protocol
濡傛灉涓汇佷粠鏈嶅姟鍣ㄥ潎鏀寔锛岀‘瀹氭槸鍚︿娇鐢ㄤ粠/涓诲帇缂╁崗璁
路 slave_load_tmpdir
浠庢湇鍔″櫒涓哄鍒LOAD DATA INFILE璇彞鍒涘缓涓存椂鏂囦欢鐨勭洰褰曞悕銆
路 slave_net_timeout
鏀惧純璇绘搷浣滃墠绛夊緟涓/浠庤繛鎺ョ殑鏇村鏁版嵁鐨勭瓑寰呯鏁般
路 slave_skip_errors
浠庢湇鍔″櫒搴旇烦杩(蹇借)鐨勫鍒堕敊璇
路 slave_transaction_retries
濡傛灉鐢变簬ofInnoDB姝婚攣鎴栬秴杩InnoDB鐨innodb_lock_wait_timeout鎴NDBCLUSTER鐨TransactionDeadlockDetectionTimeout鎴TransactionInactiveTimeout锛澶嶅埗浠庢湇鍔″櫒SQL绾跨▼鏈兘鎵ц浜嬪姟锛屽湪鎻愮ず閿欒骞跺仠姝㈠墠瀹冭嚜鍔ㄩ噸澶slave_transaction_retries娆° 榛樿鍊兼槸10銆
路 slow_launch_time
濡傛灉鍒涘缓绾跨▼鐨勬椂闂磋秴杩囪绉掓暟锛屾湇鍔″櫒澧炲姞Slow_launch_threads鐘舵佸彉閲忋
路 socket
Unix骞冲彴锛氱敤浜庢湰鍦板鎴风杩炴帴鐨勫鎺ュ瓧鏂囦欢銆傞粯璁や负/var/lib/mysql/mysql.sock銆
Windows锛氱敤浜庢湰鍦板鎴风杩炴帴鐨勫懡鍚嶇閬撳悕銆傞粯璁や负mysql銆
路 sort_buffer_size
姣忎釜鎺掑簭绾跨▼鍒嗛厤鐨勭紦鍐插尯鐨勫ぇ灏忋傚鍔犺鍊煎彲浠ュ姞蹇ORDER BY鎴GROUP BY鎿嶄綔銆傚弬瑙A.4.4鑺傦紝鈥淢ySQL灏嗕复鏃舵枃浠跺偍瀛樺湪鍝噷鈥銆
路 sql_mode
褰撳墠鐨勬湇鍔″櫒SQL妯″紡锛屽彲浠ュ姩鎬佽缃傚弬瑙5.3.2鑺傦紝鈥淪QL鏈嶅姟鍣ㄦā寮忊銆
路 sql_slave_skip_counter
浠庢湇鍔″櫒搴旇烦杩囩殑鏉ヨ嚜涓绘湇鍔″櫒鐨勪簨浠舵暟銆
路 storage_engine
璇ュ彉閲忔槸table_typeis鐨勫悓涔夎瘝銆傚湪MySQL 5.1涓,棣栭storage_engine銆
路 sync_binlog
濡傛灉涓烘锛屽綋姣忎釜sync_binlog'th鍐欏叆璇ヤ簩杩涘埗鏃ュ織鍚庯紝MySQL鏈嶅姟鍣ㄥ皢瀹冪殑浜岃繘鍒舵棩蹇楀悓姝ュ埌纭洏涓(fdatasync())銆傝娉ㄦ剰濡傛灉鍦autocommit妯″紡锛屾瘡鎵ц涓涓鍙ュ悜浜岃繘鍒舵棩蹇楀啓鍏ヤ竴娆★紝鍚﹀垯姣忎釜浜嬪姟鍐欏叆涓娆° 榛樿鍊兼槸0锛屼笉涓庣‖鐩樺悓姝ャ傚间负1鏄渶瀹夊叏鐨勯夋嫨锛屽洜涓哄穿婧冩椂锛屼綘鏈澶氫涪鎺変簩杩涘埗鏃ュ織涓殑涓涓鍙/浜嬪姟锛涗絾鏄紝杩欐槸鏈鎱㈢殑閫夋嫨(闄ら潪纭洏鏈夌數姹犲浠界紦瀛橈紝浠庤屼娇鍚屾宸ヤ綔杈冨揩)銆
路 sync_frm
濡傛灉璇ュ彉閲忚涓1,褰撳垱寤洪潪涓存椂琛ㄦ椂瀹冪殑.frm鏂囦欢琚悓姝ュ埌纭洏涓(fdatasync())锛涜繖鏍疯緝鎱絾鍑虹幇宕╂簝鏃惰緝瀹夊叏銆 榛樿鍊间负1銆
路 system_time_zone
鏈嶅姟鍣ㄧ郴缁熸椂鍖恒傚綋 鏈嶅姟鍣ㄥ紑濮嬫墽琛屾椂锛屽畠缁ф壙鏈哄櫒榛樿鏃跺尯璁剧疆鍊硷紝鍙互鐢辫繍琛屾湇鍔″櫒鐨勮处鎴锋垨鍦ㄥ惎鍔ㄨ剼鏈腑杩涜淇敼銆傝鍊肩敤鏉ヨ缃system_time_zone銆傚吀鍨嬫儏鍐电敤TZ鐜鍙橀噺鏉ユ寚瀹氭椂鍖恒傝繕鍙互鐢mysqld_safe鑴氭湰鐨--timez閫夐」鏉ユ寚瀹氥
路 table_cache
鎵鏈夌嚎绋嬫墦寮鐨勮〃鐨勬暟鐩傚澶ц鍊煎彲浠ュ鍔mysqld闇瑕佺殑鏂囦欢鎻忚堪绗︾殑鏁伴噺銆備綘鍙互妫鏌Opened_tables鐘舵佸彉閲忔潵妫鏌ヤ綘鏄惁闇瑕佸鍔犺〃缂撳瓨銆傚弬瑙5.3.4鑺傦紝鈥滄湇鍔″櫒鐘舵佸彉閲忊銆傚鏋Opened_tables鍊艰緝澶э紝骞朵笖澶氭鎵цFLUSH TABLES(鍙槸寮哄埗鍏抽棴鎵鏈夎〃骞堕噸鏂)锛屽垯搴斿鍔table_cache鍙橀噺鐨勫笺
鍏充簬琛ㄧ紦瀛樼殑璇︾粏淇℃伅锛屽弬瑙7.4.9鑺傦紝鈥淢ySQL濡備綍鎵撳紑鍜屽叧闂〃鈥銆
路 table_type
榛樿琛ㄧ被鍨(瀛樺偍寮曟搸)銆傝鎯冲湪鏈嶅姟鍣ㄥ惎鍔ㄦ椂璁剧疆琛ㄧ被鍨嬶紝浣跨敤--default-table-type閫夐」銆傚弬瑙5.3.1鑺傦紝鈥mysqld鍛戒护琛岄夐」鈥銆
路 thread_cache_size
鏈嶅姟鍣ㄥ簲缂撳瓨澶氬皯绾跨▼浠ヤ究閲嶆柊浣跨敤銆傚綋瀹㈡埛绔柇寮杩炴帴鏃讹紝濡傛灉绾跨▼灏戜簬thread_cache_size锛屽垯瀹㈡埛绔殑绾跨▼琚斁鍏ョ紦瀛樸傚綋璇锋眰绾跨▼鏃跺鏋滃厑璁稿彲浠ヤ粠缂撳瓨涓噸鏂板埄鐢ㄧ嚎绋嬶紝骞朵笖鍙湁褰撶紦瀛樼┖浜嗘椂鎵嶄細鍒涘缓鏂扮嚎绋嬨傚鏋滄柊杩炴帴寰堝锛屽彲浠ュ鍔犺鍙橀噺浠ユ彁楂樻ц兘銆(涓鑸儏鍐碉紝濡傛灉绾跨▼鎵ц寰楀緢濂斤紝鎬ц兘鎻愰珮涓嶆槑鏄)銆傛鏌Connections鍜Threads_created鐘舵佸彉閲忕殑宸(璇﹁5.3.4鑺傦紝鈥滄湇鍔″櫒鐘舵佸彉閲忊)锛屼綘鍙互鐪嬭绾跨▼缂撳瓨鐨勬晥鐜囥
路 thread_concurrency
鍦Solaris涓紝mysqld鐢ㄨ鍊艰皟鐢thr_setconcurrency()銆傝鍑芥暟浣垮簲鐢ㄧ▼搴忓悜绾跨▼绯荤粺鎻愪緵闇瑕佸悓鏃惰繍琛岀殑鏈熸湜鐨勭嚎绋嬫暟鐩殑鎻愮ず銆
路 thread_stack
姣忎釜绾跨▼鐨勫爢鏍堝ぇ灏忋傜敤crash-me娴嬭瘯妫娴嬪嚭鐨勮澶氶檺鍒跺彇鍐充簬璇ュ笺 榛樿鍊艰冻澶熷ぇ锛屽彲浠ユ弧瓒虫櫘閫氭搷浣溿傚弬瑙7.1.4鑺傦紝鈥淢ySQL鍩哄噯濂椾欢鈥銆
路 time_format
璇ュ彉閲忎负浣跨敤銆
路 time_zone
褰撳墠鐨勬椂鍖恒傚垵浣垮兼槸'SYSTEM'(浣跨敤system_time_zone鐨勫)锛屼絾鍙互鐢--default-time-zone閫夐」鍦ㄦ湇鍔″櫒鍚姩鏃舵樉寮忔寚瀹氥
路 tmp_table_size
濡傛灉鍐呭瓨鍐呯殑涓存椂琛ㄨ秴杩囪鍊硷紝MySQL鑷姩灏嗗畠杞崲涓虹‖鐩樹笂鐨MyISAM琛ㄣ傚鏋滀綘鎵ц璁稿楂樼骇GROUP BY鏌ヨ骞朵笖鏈夊ぇ閲忓唴瀛橈紝鍒欏彲浠ュ鍔tmp_table_size鐨勫笺
路 tmpdir
淇濆瓨涓存椂鏂囦欢鍜屼复鏃惰〃鐨勭洰褰曘傝鍙橀噺鍙互璁剧疆涓哄嚑涓矾寰勶紝鎸round-robin妯″紡浣跨敤銆傚湪Unix涓簲璇ョ敤鍐掑彿(鈥:鈥)闂撮殧寮璺緞锛屽湪Windows銆NetWare鍜OS/2涓敤鍒嗗彿(鈥锛鈥)銆
鐢ㄦ潵灏嗚礋鑽峰垎鏁e埌鍑犱釜鐗╃悊纭洏涓娿傚鏋MySQL鏈嶅姟鍣ㄤ负澶嶅埗浠庢湇鍔″櫒锛屼綘涓嶅簲灏tmpdir璁剧疆涓烘寚鍚戝熀浜庡唴瀛樼殑鏂囦欢绯荤粺涓婄殑鐩綍鎴栧綋鏈嶅姟鍣ㄤ富鏈洪噸鍚椂澹版槑鐨勭洰褰曘傚鍒朵粠鏈嶅姟鍣ㄩ渶瑕侀儴鍒嗕复鏃舵枃浠舵潵鍦ㄦ満鍣ㄩ噸鍚悗浠嶅彲鐢紝浠ヤ究瀹冨彲浠ュ鍒朵复鏃惰〃鎴栨墽琛LOAD DATA INFILE鎿嶄綔銆傚鏋滄湇鍔″櫒閲嶅惎鏃朵复鏃舵枃浠跺す涓殑鏂囦欢涓㈠け浜嗭紝鍒欏鍒跺け璐ャ備絾鏄紝濡傛灉浣犱娇鐢MySQL 4.0.0鎴栨洿鏂扮増鏈紝浣犲彲浠ヤ娇鐢 slave_load_tmpdir鍙橀噺璁剧疆浠庢湇鍔″櫒鐨勪复鏃剁洰褰曘傚湪杩欑鎯呭喌涓嬶紝浠庢湇鍔″櫒涓嶅啀浣跨敤甯歌tmpdir锛岃鏄庝綘鍙互灏tmpdir璁剧疆鍒颁竴涓潪鍥哄畾浣嶇疆銆
路 transaction_alloc_block_size
涓轰繚瀛樺皢淇濆瓨鍒颁簩杩涘埗鏃ュ織涓殑浜嬪姟鐨勬煡璇㈣屽垎閰嶇殑鍐呭瓨鍧楃殑澶у皬(瀛楄妭)銆
路 transaction_prealloc_size
涓transaction_alloc_blocks鍒嗛厤鐨勫浐瀹氱紦鍐插尯鐨勫ぇ灏忥紙瀛楄妭锛夛紝鍦ㄤ袱娆℃煡璇箣闂翠笉浼氶噴鏀俱備娇璇ュ艰冻澶熷ぇ锛屽皢鎵鏈夋煡璇㈠浐瀹氬埌涓涓簨鍔′腑锛屽彲浠ラ伩鍏嶅娆malloc()璋冪敤銆
路 tx_isolation
榛樿浜嬪姟闅旂绾у埆銆傞粯璁ゅ间负REPEATABLE-READ銆
路 updatable_views_with_limit
璇ュ彉閲忔帶鍒跺鏋滄洿鏂板寘鍚LIMIT瀛愬彞锛屾槸鍚﹀彲浠ュ湪褰撳墠琛ㄤ腑浣跨敤涓嶅寘鍚富鍏抽敭瀛楃殑瑙嗗浘杩涜鏇存柊銆(閫氬父鐢GUI宸ュ叿鐢熸垚杩欑被鏇存柊)銆傛洿鏂版寚UPDATE鎴DELETE璇彞銆傝繖鍎夸富鍏抽敭瀛楁寚PRIMARY KEY锛屾垨涓涓UNIQUE绱㈠紩锛屽叾涓换浣曞垪涓嶅彲浠ュ寘鍚NULL銆
璇ュ彉閲忔湁涓や釜鍊硷細
o 1鎴YES锛氬彧鍙戝嚭璀﹀憡(娌℃湁閿欒娑堟伅)銆傝繖鏄 榛樿鍊笺
o 0鎴NO锛氱姝㈡洿鏂般
路 version
鏈嶅姟鍣ㄧ増鏈彿銆
路 version_bdb
BDB瀛樺偍寮曟搸鐗堟湰銆
路 version_comment
configure鑴氭湰鏈変竴涓--with-comment閫夐」锛屽綋鏋勫缓MySQL鏃跺彲浠ヨ繘琛屾敞閲娿傝鍙橀噺鍖呭惈娉ㄩ噴鍊笺
路 version_compile_machine
MySQL鏋勫缓鐨勬満鍣ㄦ垨鏋舵瀯鐨勭被鍨嬨
路 version_compile_os
MySQL鏋勫缓鐨勬搷浣滅郴缁熺殑绫诲瀷銆
路 wait_timeout
鏈嶅姟鍣ㄥ叧闂潪浜や簰杩炴帴涔嬪墠绛夊緟娲诲姩鐨勭鏁般
鍦ㄧ嚎绋嬪惎鍔ㄦ椂锛屾牴鎹叏灞wait_timeout鍊兼垨鍏ㄥ眬interactive_timeout鍊煎垵濮嬪寲浼氳瘽wait_timeout鍊硷紝鍙栧喅浜庡鎴风绫诲瀷(鐢mysql_real_connect()鐨勮繛鎺ラ夐」CLIENT_INTERACTIVE瀹氫箟)銆傚張瑙interactive_timeout銆
璁稿鏈嶅姟鍣ㄧ郴缁熷彉閲忔槸鍔ㄦ佺殑锛屽彲浠ヤ娇鐢SET GLOBAL鎴SET SESSION鍦ㄨ繍琛屾椂璁剧疆銆備綘杩樺彲浠ヤ娇鐢SELECT鑾峰緱瀹冧滑鐨勫笺傚弬瑙9.4鑺傦紝鈥滅郴缁熷彉閲忊銆
涓嬮潰鐨勮〃鍒楀嚭浜嗘墍鏈夊姩鎬佺郴缁熷彉閲忋傛渶鍚1鍒楄鏄庢瘡涓彉閲忔槸鍚﹂傜敤GLOBAL鎴SESSION(鎴栦簩鑰)銆
鍙橀噺鍚 |
鍊肩被鍨 |
绫诲瀷 |
autocommit |
boolean |
SESSION |
big_tables |
boolean |
SESSION |
binlog_cache_size |
numeric |
GLOBAL |
bulk_insert_buffer_size |
numeric |
GLOBAL | SESSION |
character_set_client |
string |
GLOBAL | SESSION |
character_set_connection |
string |
GLOBAL | SESSION |
character_set_results |
string |
GLOBAL | SESSION |
character_set_server |
string |
GLOBAL | SESSION |
collation_connection |
string |
GLOBAL | SESSION |
collation_server |
string |
GLOBAL | SESSION |
completion_type |
numeric |
GLOBAL | SESSION |
concurrent_insert |
boolean |
GLOBAL |
connect_timeout |
numeric |
GLOBAL |
convert_character_set |
string |
GLOBAL | SESSION |
default_week_format |
numeric |
GLOBAL | SESSION |
delay_key_write |
OFF | ON | ALL |
GLOBAL |
delayed_insert_limit |
numeric |
GLOBAL |
delayed_insert_timeout |
numeric |
GLOBAL |
delayed_queue_size |
numeric |
GLOBAL |
div_precision_increment |
numeric |
GLOBAL | SESSION |
engine_condition_pushdown |
boolean |
GLOBAL | SESSION |
error_count |
numeric |
SESSION |
expire_logs_days |
numeric |
GLOBAL |
flush |
boolean |
GLOBAL |
flush_time |
numeric |
GLOBAL |
foreign_key_checks |
boolean |
SESSION |
ft_boolean_syntax |
numeric |
GLOBAL |
group_concat_max_len |
numeric |
GLOBAL | SESSION |
identity |
numeric |
SESSION |
innodb_autoextend_increment |
numeric |
GLOBAL |
innodb_concurrency_tickets |
numeric |
GLOBAL |
innodb_max_dirty_pages_pct |
numeric |
GLOBAL |
innodb_max_purge_lag |
numeric |
GLOBAL |
innodb_support_xa |
boolean |
GLOBAL | SESSION |
innodb_sync_spin_loops |
numeric |
GLOBAL |
innodb_table_locks |
boolean |
GLOBAL | SESSION |
innodb_thread_concurrency |
numeric GLOBAL |
|
innodb_thread_sleep_delay |
numeric GLOBAL |
|
insert_id |
boolean |
SESSION |
interactive_timeout |
numeric |
GLOBAL | SESSION |
join_buffer_size |
numeric |
GLOBAL | SESSION |
key_buffer_size |
numeric |
GLOBAL |
last_insert_id |
numeric |
SESSION |
local_infile |
boolean |
GLOBAL |
log_warnings |
numeric |
GLOBAL |
long_query_time |
numeric |
GLOBAL | SESSION |
low_priority_updates |
boolean |
GLOBAL | SESSION |
max_allowed_packet |
numeric |
GLOBAL | SESSION |
max_binlog_cache_size |
numeric |
GLOBAL |
max_binlog_size |
numeric |
GLOBAL |
max_connect_errors |
numeric |
GLOBAL |
max_connections |
numeric |
GLOBAL |
max_delayed_threads |
numeric |
GLOBAL |
max_error_count |
numeric |
GLOBAL | SESSION |
max_heap_table_size |
numeric |
GLOBAL | SESSION |
max_insert_delayed_threads |
numeric |
GLOBAL |
max_join_size |
numeric |
GLOBAL | SESSION |
max_relay_log_size |
numeric |
GLOBAL |
max_seeks_for_key |
numeric |
GLOBAL | SESSION |
max_sort_length |
numeric |
GLOBAL | SESSION |
max_tmp_tables |
numeric |
GLOBAL | SESSION |
max_user_connections |
numeric |
GLOBAL |
max_write_lock_count |
numeric |
GLOBAL |
myisam_stats_method |
enum |
GLOBAL | SESSION |
multi_read_range |
numeric |
GLOBAL | SESSION |
myisam_data_pointer_size |
numeric |
GLOBAL |
log_bin_trust_routine_creators |
boolean |
GLOBAL |
myisam_max_sort_file_size |
numeric |
GLOBAL | SESSION |
myisam_repair_threads |
numeric |
GLOBAL | SESSION |
myisam_sort_buffer_size |
numeric |
GLOBAL | SESSION |
net_buffer_length |
numeric |
GLOBAL | SESSION |
net_read_timeout |
numeric |
GLOBAL | SESSION |
net_retry_count |
numeric |
GLOBAL | SESSION |
net_write_timeout |
numeric |
GLOBAL | SESSION |
old_passwords |
numeric |
GLOBAL | SESSION |
optimizer_prune_level |
numeric |
GLOBAL | SESSION |
optimizer_search_depth |
numeric |
GLOBAL | SESSION |
preload_buffer_size |
numeric |
GLOBAL | SESSION |
query_alloc_block_size |
numeric |
GLOBAL | SESSION |
query_cache_limit |
numeric |
GLOBAL |
query_cache_size |
numeric |
GLOBAL |
query_cache_type |
enumeration |
GLOBAL | SESSION |
query_cache_wlock_invalidate |
boolean |
GLOBAL | SESSION |
query_prealloc_size |
numeric |
GLOBAL | SESSION |
range_alloc_block_size |
numeric |
GLOBAL | SESSION |
read_buffer_size |
numeric |
GLOBAL | SESSION |
read_only |
numeric |
GLOBAL |
read_rnd_buffer_size |
numeric |
GLOBAL | SESSION |
rpl_recovery_rank |
numeric |
GLOBAL |
safe_show_database |
boolean |
GLOBAL |
secure_auth |
boolean |
GLOBAL |
server_id |
numeric |
GLOBAL |
slave_compressed_protocol |
boolean |
GLOBAL |
slave_net_timeout |
numeric |
GLOBAL |
slave_transaction_retries |
numeric |
GLOBAL |
slow_launch_time |
numeric |
GLOBAL |
sort_buffer_size |
numeric |
GLOBAL | SESSION |
sql_auto_is_null |
boolean |
SESSION |
sql_big_selects |
boolean |
SESSION |
sql_big_tables |
boolean |
SESSION |
sql_buffer_result |
boolean |
SESSION |
sql_log_bin |
boolean |
SESSION |
sql_log_off |
boolean |
SESSION |
sql_log_update |
boolean |
SESSION |
sql_low_priority_updates |
boolean |
GLOBAL | SESSION |
sql_max_join_size |
numeric |
GLOBAL | SESSION |
sql_mode |
enumeration |
GLOBAL | SESSION |
sql_notes |
boolean |
SESSION |
sql_quote_show_create |
boolean |
SESSION |
sql_safe_updates |
boolean |
SESSION |
sql_select_limit |
numeric |
SESSION |
sql_slave_skip_counter |
numeric |
GLOBAL |
updatable_views_with_limit |
enumeration |
GLOBAL | SESSION |
sql_warnings |
boolean |
SESSION |
sync_binlog |
numeric |
GLOBAL |
sync_frm |
boolean |
GLOBAL |
storage_engine |
enumeration |
GLOBAL | SESSION |
table_cache |
numeric |
GLOBAL |
table_type |
enumeration |
GLOBAL | SESSION |
thread_cache_size |
numeric |
GLOBAL |
time_zone |
string |
GLOBAL | SESSION |
timestamp |
boolean |
SESSION |
tmp_table_size |
enumeration |
GLOBAL | SESSION |
transaction_alloc_block_size |
numeric |
GLOBAL | SESSION |
transaction_prealloc_size |
numeric |
GLOBAL | SESSION |
tx_isolation |
enumeration |
GLOBAL | SESSION |
unique_checks |
boolean |
SESSION |
wait_timeout |
numeric |
GLOBAL | SESSION |
warning_count |
numeric |
SESSION |
鏍囪涓string鐨勫彉閲忛噰鐢ㄥ瓧绗︿覆鍊笺傛爣璁颁负numeric鐨勫彉閲忛噰鐢ㄦ暟瀛楀笺傛爣璁颁负boolean鐨勫彉閲忓彲浠ヨ缃负0銆1銆ON鎴OFF銆傛爣璁颁负enumeration鐨勫彉閲忎竴鑸儏鍐靛簲璁剧疆涓鸿鍙橀噺鐨勬煇涓彲鐢ㄥ硷紝浣嗚繕鍙互璁剧疆涓哄搴旀湡鏈涚殑鏋氫妇鍊肩殑鏁板瓧銆傚浜鏋氫妇绯荤粺鍙橀噺锛岀1涓灇涓惧煎簲瀵瑰簲0銆傝繖涓嶅悓浜ENUM鍒楋紝绗1涓灇涓惧煎搴1銆
鏈嶅姟鍣ㄧ淮鎶よ澶氭彁渚涙搷浣滅浉鍏充俊鎭殑鐘舵佸彉閲忋備綘鍙互閫氳繃SHOW STATUS璇彞鏌ョ湅杩欎簺鍙橀噺鍜屽畠浠殑鍊硷細
mysql> SHOW STATUS;
+-----------------------------------+------------+
| Variable_name | Value |
+-----------------------------------+------------+
| Aborted_clients | 0 |
| Aborted_connects | 0 |
| Bytes_received | 155372598 |
| Bytes_sent | 1176560426 |
鈥
| Connections | 30023 |
| Created_tmp_disk_tables | 0 |
| Created_tmp_files | 3 |
| Created_tmp_tables | 2 |
鈥
| Threads_created | 217 |
| Threads_running | 88 |
| Uptime | 1389872 |
+-----------------------------------+------------+
鐢FLUSH STATUS璇彞鍙互灏嗚澶氱姸鎬佸彉閲忛噸璁句负0銆
鐘舵佸彉閲忔湁浠ヤ笅鍚箟銆傛病鏈夋寚绀虹増鏈殑鍙橀噺鍦MySQL 5.1涔嬪墠宸茬粡鍑虹幇銆傚叧浜庡畠浠殑浣跨敤鍘嗗彶锛屽弬瑙MySQL 5.0鍙傝冩墜鍐銆
路 Aborted_clients
鐢变簬瀹㈡埛绔病鏈夋纭叧闂繛鎺ュ鑷村鎴风缁堟鑰屼腑鏂殑杩炴帴鏁般傚弬瑙A.2.10鑺傦紝鈥滈氫俊閿欒鍜屽け鏁堣繛鎺モ銆
路 Aborted_connects
璇曞浘杩炴帴鍒MySQL鏈嶅姟鍣ㄨ屽け璐ョ殑杩炴帴鏁般傚弬瑙A.2.10鑺傦紝鈥滈氫俊閿欒鍜屽け鏁堣繛鎺モ銆
路 Binlog_cache_disk_use
浣跨敤涓存椂浜岃繘鍒舵棩蹇楃紦瀛樹絾瓒呰繃binlog_cache_size鍊煎苟浣跨敤涓存椂鏂囦欢鏉ヤ繚瀛樹簨鍔′腑鐨勮鍙ョ殑浜嬪姟鏁伴噺銆
路 Binlog_cache_use
浣跨敤涓存椂浜岃繘鍒舵棩蹇楃紦瀛樼殑浜嬪姟鏁伴噺銆
路 Bytes_received
浠庢墍鏈夊鎴风鎺ユ敹鍒扮殑瀛楄妭鏁般
路 Bytes_sent
鍙戦佺粰鎵鏈夊鎴风鐨勫瓧鑺傛暟銆
路 Com_xxx
Com_xxx 璇彞璁℃暟鍙橀噺琛ㄧず姣忎釜xxx 璇彞鎵ц鐨勬鏁般傛瘡绫昏鍙ユ湁涓涓姸鎬佸彉閲忋備緥濡傦紝Com_delete鍜Com_insert鍒嗗埆缁熻DELETE 鍜INSERT璇彞鎵ц鐨勬鏁般
Com_stmt_xxx鐘舵佸彉閲忎负锛
o Com_stmt_prepare
o Com_stmt_execute
o Com_stmt_fetch
o Com_stmt_send_long_data
o Com_stmt_reset
o Com_stmt_close
杩欎簺鍙橀噺浠h〃鍑嗗濂界殑璇彞鍛戒护銆傚畠浠殑鍚嶅瓧瀵瑰簲缃戠粶灞備娇鐢ㄧ殑COM_xxx 鍛戒护绯诲垪锛涙崲鍙ヨ瘽璇达細褰撳噯澶囧ソ鐨勮鍙API璋冪敤濡mysql_stmt_prepare()銆mysql_stmt_鎵ц()骞舵墽琛屾椂锛屽畠浠殑鍊煎鍔犮備絾鏄紝褰撴墽琛屼笅闈㈢殑SQL璇彞鏃讹紝Com_stmt_prepare, Com_stmt_execute鍜Com_stmt_close涔熷鍔狅細PREPARE銆EXECUTE鎴DEALLOCATE PREPARE銆傛澶栵紝鏃(浠MySQL 4.1.3璧峰彲鐢)璇彞璁℃暟鍙橀噺Com_prepare_sql銆Com_execute_sql鍜Com_dealloc_sql鐨勫间篃闅PREPARE銆EXECUTE鍜DEALLOCATE PREPARE璇彞澧炲姞銆Com_stmt_fetch浠h〃閫氳繃鍏夋爣鑾峰彇鐨勭綉缁round-trips鐨勬绘暟閲忋
鎵鏈Com_stmt_xxx鍙橀噺灏嗗鍔狅紝鍗充娇璇彞鍙傛暟鏈煡鎴栨墽琛岃繃绋嬩腑鍑虹幇閿欒銆傛崲鍙ヨ瘽璇达紝瀹冧滑鐨勫煎搴斿彂鍑虹殑璇锋眰鏁帮紝鑰屼笉鏄垚鍔熷畬鎴愮殑璇锋眰鏁般
路 Connections
璇曞浘杩炴帴鍒(涓嶇鏄惁鎴愬姛)MySQL鏈嶅姟鍣ㄧ殑杩炴帴鏁般
路 Created_tmp_disk_tables
鏈嶅姟鍣ㄦ墽琛岃鍙ユ椂鍦ㄧ‖鐩樹笂鑷姩鍒涘缓鐨勪复鏃惰〃鐨勬暟閲忋
路 Created_tmp_files
mysqld宸茬粡鍒涘缓鐨勪复鏃舵枃浠剁殑鏁伴噺銆
路 Created_tmp_files
鏈嶅姟鍣ㄦ墽琛岃鍙ユ椂鑷姩鍒涘缓鐨勫唴瀛樹腑鐨勪复鏃惰〃鐨勬暟閲忋傚鏋Created_tmp_disk_tables杈冨ぇ锛屼綘鍙兘瑕佸鍔tmp_table_size鍊间娇涓存椂 琛ㄥ熀浜庡唴瀛樿屼笉鍩轰簬纭洏銆
路 Delayed_errors
鐢INSERT DELAYED鍐欑殑鍑虹幇閿欒鐨勮鏁(鍙兘涓duplicate key)銆
路 Delayed_insert_threads
浣跨敤鐨INSERT DELAYED澶勭悊鍣ㄧ嚎绋嬫暟銆
路 Delayed_writes
鍐欏叆鐨INSERT DELAYED琛屾暟銆
路 Flush_commands
鎵ц鐨FLUSH璇彞鏁般
路 Handler_commit
鍐呴儴鎻愪氦璇彞鏁般
路 Handler_discover
MySQL鏈嶅姟鍣ㄥ彲浠ラ棶NDB CLUSTER瀛樺偍寮曟搸鏄惁鐭ラ亾鏌愪竴鍚嶅瓧鐨勮〃銆傝繖琚О浣滃彂鐜般Handler_discover璇存槑閫氳繃璇ユ柟娉曞彂鐜扮殑娆℃暟銆
路 Handler_delete
琛屼粠琛ㄤ腑鍒犻櫎鐨勬鏁般
路 Handler_read_first
绱㈠紩涓涓鏉¤璇荤殑娆℃暟銆傚鏋滆緝楂橈紝瀹冨缓璁湇鍔″櫒姝f墽琛屽ぇ閲忓叏绱㈠紩鎵弿锛涗緥濡傦紝SELECT col1 FROM foo锛屽亣瀹col1鏈夌储寮曘
路 Handler_read_key
鏍规嵁閿涓琛岀殑璇锋眰鏁般傚鏋滆緝楂橈紝璇存槑鏌ヨ鍜岃〃鐨勭储寮曟纭
路 Handler_read_next
鎸夌収閿『搴忚涓嬩竴琛岀殑璇锋眰鏁般傚鏋滀綘鐢ㄨ寖鍥寸害鏉熸垨濡傛灉鎵ц绱㈠紩鎵弿鏉ユ煡璇㈢储寮曞垪锛岃鍊煎鍔犮
路 Handler_read_prev
鎸夌収閿『搴忚鍓嶄竴琛岀殑璇锋眰鏁般傝璇绘柟娉曚富瑕佺敤浜庝紭鍖ORDER BY ... DESC銆
路 Handler_read_rnd
鏍规嵁鍥哄畾浣嶇疆璇讳竴琛岀殑璇锋眰鏁般傚鏋滀綘姝f墽琛屽ぇ閲忔煡璇㈠苟闇瑕佸缁撴灉杩涜鎺掑簭璇ュ艰緝楂樸備綘鍙兘浣跨敤浜嗗ぇ閲忛渶瑕MySQL鎵弿鏁翠釜琛ㄧ殑鏌ヨ鎴栦綘鐨勮繛鎺ユ病鏈夋纭娇鐢ㄩ敭銆
路 Handler_read_rnd_next
鍦ㄦ暟鎹枃浠朵腑璇讳笅涓琛岀殑璇锋眰鏁般傚鏋滀綘姝h繘琛屽ぇ閲忕殑琛ㄦ壂鎻忥紝璇ュ艰緝楂樸傞氬父璇存槑浣犵殑琛ㄧ储寮曚笉姝g‘鎴栧啓鍏ョ殑鏌ヨ娌℃湁鍒╃敤绱㈠紩銆
路 Handler_rollback
鍐呴儴ROLLBACK璇彞鐨勬暟閲忋
路 Handler_update
鍦ㄨ〃鍐呮洿鏂颁竴琛岀殑璇锋眰鏁般
路 Handler_write
鍦ㄨ〃鍐呮彃鍏ヤ竴琛岀殑璇锋眰鏁般
路 Innodb_buffer_pool_pages_data
鍖呭惈鏁版嵁鐨勯〉鏁(鑴忔垨骞插噣)銆
路 Innodb_buffer_pool_pages_dirty
褰撳墠鐨勮剰椤垫暟銆
路 Innodb_buffer_pool_pages_flushed
瑕佹眰娓呯┖鐨勭紦鍐叉睜椤垫暟銆
路 Innodb_buffer_pool_pages_free
绌洪〉鏁般
路 Innodb_buffer_pool_pages_latched
鍦InnoDB缂撳啿姹犱腑閿佸畾鐨勯〉鏁般傝繖鏄綋鍓嶆璇绘垨鍐欐垨鐢变簬鍏跺畠鍘熷洜涓嶈兘娓呯┖鎴栧垹闄ょ殑椤垫暟銆
路 Innodb_buffer_pool_pages_misc
蹇欑殑椤垫暟锛屽洜涓哄畠浠凡缁忚鍒嗛厤浼樺厛鐢ㄤ綔绠$悊锛屼緥濡傝閿佸畾鎴栭傜敤鐨勫搱甯岀储寮曘傝鍊艰繕鍙互璁$畻涓Innodb_buffer_pool_pages_total - Innodb_buffer_pool_pages_free - Innodb_buffer_pool_pages_data銆
路 Innodb_buffer_pool_pages_total
缂撳啿姹犳诲ぇ灏忥紙椤垫暟锛夈
路 Innodb_buffer_pool_read_ahead_rnd
InnoDB鍒濆鍖栫殑鈥闅忔満鈥read-aheads鏁般傚綋鏌ヨ浠ラ殢鏈洪『搴忔壂鎻忚〃鐨勪竴澶ч儴鍒嗘椂鍙戠敓銆
路 Innodb_buffer_pool_read_ahead_seq
InnoDB鍒濆鍖栫殑椤哄簭read-aheads鏁般傚綋InnoDB鎵ц椤哄簭鍏ㄨ〃鎵弿鏃跺彂鐢熴
路 Innodb_buffer_pool_read_requests
InnoDB宸茬粡瀹屾垚鐨勯昏緫璇昏姹傛暟銆
路 Innodb_buffer_pool_reads
涓嶈兘婊¤冻InnoDB蹇呴』鍗曢〉璇诲彇鐨勭紦鍐叉睜涓殑閫昏緫璇绘暟閲忋
路 Innodb_buffer_pool_wait_free
涓鑸儏鍐碉紝閫氳繃鍚庡彴鍚InnoDB缂撳啿姹犲啓銆備絾鏄紝濡傛灉闇瑕佽鎴栧垱寤洪〉锛屽苟涓旀病鏈夊共鍑鐨勯〉鍙敤锛屽垯瀹冭繕闇瑕佸厛绛夊緟椤甸潰娓呯┖銆傝璁℃暟鍣ㄥ绛夊緟瀹炰緥杩涜璁版暟銆傚鏋滃凡缁忛傚綋璁剧疆缂撳啿姹犲ぇ灏忥紝璇ュ煎簲灏忋
路 Innodb_buffer_pool_write_requests
鍚InnoDB缂撳啿姹犵殑鍐欐暟閲忋
路 Innodb_data_fsyncs
fsync()鎿嶄綔鏁般
路 Innodb_data_pending_fsyncs
褰撳墠鎸傝捣鐨fsync()鎿嶄綔鏁般
路 Innodb_data_pending_reads
褰撳墠鎸傝捣鐨勮鏁般
路 Innodb_data_pending_writes
褰撳墠鎸傝捣鐨勫啓鏁般
路 Innodb_data_read
鑷虫宸茬粡璇诲彇鐨勬暟鎹暟閲忥紙瀛楄妭锛夈
路 Innodb_data_reads
鏁版嵁璇绘绘暟閲忋
路 Innodb_data_writes
鏁版嵁鍐欐绘暟閲忋
路 Innodb_data_written
鑷虫宸茬粡鍐欏叆鐨勬暟鎹噺锛堝瓧鑺傦級銆
路 Innodb_dblwr_writes, Innodb_dblwr_pages_written
宸茬粡鎵ц鐨勫弻鍐欐搷浣滄暟閲忓拰涓烘鐩殑宸茬粡鍐欏ソ鐨勯〉鏁般傚弬瑙15.2.14.1鑺傦紝鈥滅鐩業/O鈥銆
路 Innodb_log_waits
鎴戜滑蹇呴』绛夊緟鐨勬椂闂达紝鍥犱负鏃ュ織缂撳啿鍖哄お灏忥紝鎴戜滑鍦ㄧ户缁墠蹇呴』鍏堢瓑寰呭瀹冩竻绌恒
路 Innodb_log_write_requests
鏃ュ織鍐欒姹傛暟銆
路 Innodb_log_writes
鍚戞棩蹇楁枃浠剁殑鐗╃悊鍐欐暟閲忋
路 Innodb_os_log_fsyncs
鍚戞棩蹇楁枃浠跺畬鎴愮殑fsync()鍐欐暟閲忋
路 Innodb_os_log_pending_fsyncs
鎸傝捣鐨勬棩蹇楁枃浠fsync()鎿嶄綔鏁伴噺銆
路 Innodb_os_log_pending_writes
鎸傝捣鐨勬棩蹇楁枃浠跺啓鎿嶄綔銆
路 Innodb_os_log_written
鍐欏叆鏃ュ織鏂囦欢鐨勫瓧鑺傛暟銆
路 Innodb_page_size
缂栬瘧鐨InnoDB椤靛ぇ灏(榛樿16KB)銆傝澶氬肩敤椤垫潵璁版暟锛涢〉鐨勫ぇ灏忓緢瀹规槗杞崲涓哄瓧鑺傘
路 Innodb_pages_created
鍒涘缓鐨勯〉鏁般
路 Innodb_pages_read
璇诲彇鐨勯〉鏁般
路 Innodb_pages_written
鍐欏叆鐨勯〉鏁般
路 Innodb_row_lock_current_waits
褰撳墠绛夊緟鐨勫緟閿佸畾鐨勮鏁般
路 Innodb_row_lock_time
琛岄攣瀹氳姳璐圭殑鎬绘椂闂达紝鍗曚綅姣銆
路 Innodb_row_lock_time_avg
琛岄攣瀹氱殑骞冲潎鏃堕棿锛屽崟浣嶆绉掋
路 Innodb_row_lock_time_max
琛岄攣瀹氱殑鏈闀挎椂闂达紝鍗曚綅姣銆
路 Innodb_row_lock_waits
涓琛岄攣瀹氬繀椤荤瓑寰呯殑鏃堕棿鏁般
路 Innodb_rows_deleted
浠InnoDB琛ㄥ垹闄ょ殑琛屾暟銆
路 Innodb_rows_inserted
鎻掑叆鍒InnoDB琛ㄧ殑琛屾暟銆
路 Innodb_rows_read
浠InnoDB琛ㄨ鍙栫殑琛屾暟銆
路 Innodb_rows_updated
InnoDB琛ㄥ唴鏇存柊鐨勮鏁般
路 Key_blocks_not_flushed
閿紦瀛樺唴宸茬粡鏇存敼浣嗚繕娌℃湁娓呯┖鍒扮‖鐩樹笂鐨勯敭鐨勬暟鎹潡鏁伴噺銆
路 Key_blocks_unused
閿紦瀛樺唴鏈娇鐢ㄧ殑鍧楁暟閲忋備綘鍙互浣跨敤璇ュ兼潵纭畾浣跨敤浜嗗灏戦敭缂撳瓨锛涘弬瑙5.3.3鑺傦紝鈥滄湇鍔″櫒绯荤粺鍙橀噺鈥涓Key_buffer_size鐨勮璁恒
路 Key_blocks_used
閿紦瀛樺唴浣跨敤鐨勫潡鏁伴噺銆傝鍊间负楂樻按骞崇嚎鏍囪锛岃鏄庡凡缁忓悓鏃舵渶澶氫娇鐢ㄤ簡澶氬皯鍧椼
路 Key_read_requests
浠庣紦瀛樿閿殑鏁版嵁鍧楃殑璇锋眰鏁般
路 Key_reads
浠庣‖鐩樿鍙栭敭鐨勬暟鎹潡鐨勬鏁般傚鏋Key_reads杈冨ぇ锛屽垯Key_buffer_size鍊煎彲鑳藉お灏忋傚彲浠ョ敤Key_reads/Key_read_requests璁$畻缂撳瓨鎹熷け鐜囥
路 Key_write_requests
灏嗛敭鐨勬暟鎹潡鍐欏叆缂撳瓨鐨勮姹傛暟銆
路 Key_writes
鍚戠‖鐩樺啓鍏ュ皢閿殑鏁版嵁鍧楃殑鐗╃悊鍐欐搷浣滅殑娆℃暟銆
路 Last_query_cost
鐢ㄦ煡璇紭鍖栧櫒璁$畻鐨勬渶鍚庣紪璇戠殑鏌ヨ鐨勬绘垚鏈傜敤浜庡姣斿悓涓鏌ヨ鐨勪笉鍚屾煡璇㈡柟妗堢殑鎴愭湰銆傞粯璁ゅ0琛ㄧず杩樻病鏈夌紪璇戞煡璇€ 榛樿鍊兼槸0銆Last_query_cost鍏锋湁浼氳瘽鑼冨洿銆
路 Max_used_connections
鏈嶅姟鍣ㄥ惎鍔ㄥ悗宸茬粡鍚屾椂浣跨敤鐨勮繛鎺ョ殑鏈澶ф暟閲忋
路 Not_flushed_delayed_rows
绛夊緟鍐欏叆INSERT DELAY闃熷垪鐨勮鏁般
路 Open_files
鎵撳紑鐨勬枃浠剁殑鏁扮洰銆
路 Open_streams
鎵撳紑鐨勬祦鐨勬暟閲(涓昏鐢ㄤ簬璁板綍)銆
路 Open_tables
褰撳墠鎵撳紑鐨勮〃鐨勬暟閲忋
路 Opened_tables
宸茬粡鎵撳紑鐨勮〃鐨勬暟閲忋傚鏋Opened_tables杈冨ぇ锛table_cache 鍊煎彲鑳藉お灏忋
路 QCACHE_free_blocks
鏌ヨ缂撳瓨鍐呰嚜鐢卞唴瀛樺潡鐨勬暟閲忋
路 QCACHE_free_memory
鐢ㄤ簬鏌ヨ缂撳瓨鐨勮嚜鐢卞唴瀛樼殑鏁伴噺銆
路 QCACHE_hits
鏌ヨ缂撳瓨琚闂殑娆℃暟銆
路 QCACHE_inserts
鍔犲叆鍒扮紦瀛樼殑鏌ヨ鏁伴噺銆
路 QCACHE_lowmem_prunes
鐢变簬鍐呭瓨杈冨皯浠庣紦瀛樺垹闄ょ殑鏌ヨ鏁伴噺銆
路 QCACHE_not_cached
闈炵紦瀛樻煡璇㈡暟(涓嶅彲缂撳瓨锛屾垨鐢变簬query_cache_type璁惧畾鍊兼湭缂撳瓨)銆
路 Qcache_queries_in_cache
鐧昏鍒扮紦瀛樺唴鐨勬煡璇㈢殑鏁伴噺銆
路 Qcache_total_blocks
鏌ヨ缂撳瓨鍐呯殑鎬诲潡鏁般
路 Questions
宸茬粡鍙戦佺粰鏈嶅姟鍣ㄧ殑鏌ヨ鐨勪釜鏁般
路 Rpl_status
澶辫触瀹夊叏澶嶅埗鐘舵(杩樻湭浣跨敤)銆
路 Select_full_join
娌℃湁浣跨敤绱㈠紩鐨勮仈鎺ョ殑鏁伴噺銆傚鏋滆鍊间笉涓0,浣犲簲浠旂粏妫鏌ヨ〃鐨勭储寮曘
路 Select_full_range_join
鍦ㄥ紩鐢ㄧ殑琛ㄤ腑浣跨敤鑼冨洿鎼滅储鐨勮仈鎺ョ殑鏁伴噺銆
路 Select_range
鍦ㄧ涓涓〃涓娇鐢ㄨ寖鍥寸殑鑱旀帴鐨勬暟閲忋備竴鑸儏鍐典笉鏄叧閿棶棰橈紝鍗充娇璇ュ肩浉褰撳ぇ銆
路 Select_range_check
鍦ㄦ瘡涓琛屾暟鎹悗瀵归敭鍊艰繘琛屾鏌ョ殑涓嶅甫閿肩殑鑱旀帴鐨勬暟閲忋傚鏋滀笉涓0锛屼綘搴斾粩缁嗘鏌ヨ〃鐨勭储寮曘
路 Select_scan
瀵圭涓涓〃杩涜瀹屽叏鎵弿鐨勮仈鎺ョ殑鏁伴噺銆
路 Slave_open_temp_tables
褰撳墠鐢变粠SQL绾跨▼鎵撳紑鐨勪复鏃惰〃鐨勬暟閲忋
路 Slave_running
濡傛灉璇ユ湇鍔″櫒鏄繛鎺ュ埌涓绘湇鍔″櫒鐨勪粠鏈嶅姟鍣紝鍒欒鍊间负ON銆
路 Slave_retried_transactions
鍚姩鍚庡鍒朵粠鏈嶅姟鍣SQL绾跨▼灏濊瘯浜嬪姟鐨勬绘鏁般
路 Slow_launch_threads
鍒涘缓鏃堕棿瓒呰繃slow_launch_time绉掔殑绾跨▼鏁般
路 Slow_queries
鏌ヨ鏃堕棿瓒呰繃long_query_time绉掔殑鏌ヨ鐨勪釜鏁般傚弬瑙5.11.4鑺傦紝鈥滄參閫熸煡璇㈡棩蹇椻銆
路 Sort_merge_passes
鎺掑簭绠楁硶宸茬粡鎵ц鐨勫悎骞剁殑鏁伴噺銆傚鏋滆繖涓彉閲忓艰緝澶э紝搴旇冭檻澧炲姞sort_buffer_size绯荤粺鍙橀噺鐨勫笺
路 Sort_range
鍦ㄨ寖鍥村唴鎵ц鐨勬帓搴忕殑鏁伴噺銆
路 Sort_rows
宸茬粡鎺掑簭鐨勮鏁般
路 Sort_scan
閫氳繃鎵弿琛ㄥ畬鎴愮殑鎺掑簭鐨勬暟閲忋
路 Ssl_xxx
鐢ㄤ簬SSL杩炴帴鐨勫彉閲忋
路 Table_locks_immediate
绔嬪嵆鑾峰緱鐨勮〃鐨勯攣鐨勬鏁般
路 Table_locks_waited
涓嶈兘绔嬪嵆鑾峰緱鐨勮〃鐨勯攣鐨勬鏁般傚鏋滆鍊艰緝楂橈紝骞朵笖鏈夋ц兘闂锛屼綘搴旈鍏堜紭鍖栨煡璇紝鐒跺悗鎷嗗垎琛ㄦ垨浣跨敤澶嶅埗銆
路 Threads_cached
绾跨▼缂撳瓨鍐呯殑绾跨▼鐨勬暟閲忋
路 Threads_connected
褰撳墠鎵撳紑鐨勮繛鎺ョ殑鏁伴噺銆
路 Threads_created
鍒涘缓鐢ㄦ潵澶勭悊杩炴帴鐨勭嚎绋嬫暟銆傚鏋Threads_created杈冨ぇ锛屼綘鍙兘瑕佸鍔thread_cache_size鍊笺傜紦瀛樿闂巼鐨勮绠楁柟娉Threads_created/Connections銆
路 Threads_running
婵娲荤殑锛堥潪鐫$湢鐘舵侊級绾跨▼鏁般
路 Uptime
鏈嶅姟鍣ㄥ凡缁忚繍琛岀殑鏃堕棿锛堜互绉掍负鍗曚綅锛夈
鍦Unix鎴Unix绫荤郴缁熶腑锛岃繍琛mysql_fix_privilege_tables鑴氭湰鏉ユ洿鏂扮郴缁熻〃锛
shell> mysql_fix_privilege_tables
浣犲繀椤诲湪鏈嶅姟鍣ㄨ繍琛屾椂鎵ц璇ヨ剼鏈傚畠璇曞浘杩炴帴鏈満涓婄敤root杩愯鐨勬湇鍔″櫒銆傚鏋root璐︽埛闇瑕佸瘑鐮侊紝鍦ㄥ懡浠よ涓寜涓嬭堪鏂规硶缁欏嚭瀵嗙爜锛
shell> mysql_fix_privilege_tables--password=root_password
mysql_fix_privilege_tables鑴氭湰鍙互鎵ц灏嗙郴缁熻〃杞崲涓哄綋鍓嶆牸寮忕殑浠讳綍鍔ㄤ綔銆傝繍琛屾椂浣犲彲鑳戒細鐪嬭涓浜Duplicate column name璀﹀憡锛涗綘鍙互蹇界暐瀹冧滑銆
杩愯瀹岃剼鏈悗锛屽仠姝㈡湇鍔″櫒骞堕噸鍚
鍦Windows绯荤粺涓紝MySQL鍒嗗彂鍖呮嫭mysql_fix_privilege_tables.sql SQL鑴氭湰锛屼綘鍙互鐢mysql瀹㈡埛绔潵杩愯銆備緥濡傦紝濡傛灉MySQL瀹夎鍒C:\Program Files\MySQL\MySQL Server 5.1锛屽懡浠ゅ簲涓猴細
C:\> C:\Program Files\MySQL\MySQL Server 5.1\bin\mysql -u root -p mysql
mysql> SOURCE C:/Program Files/MySQL/MySQL Server 5.1/scripts/mysql_fix_privilege_tables.sql
濡傛灉瀹夎鍒板叾瀹冪洰褰曪紝鐩稿簲鍦版洿鏀硅矾寰勫悕銆
mysql鍛戒护灏嗘彁绀鸿緭鍏root瀵嗙爜锛涙寜鐓ф彁绀鸿緭鍏ュ瘑鐮併
鍦Unix涓紝褰mysql澶勭悊mysql_fix_privilege_tables.sql script鑴氭湰涓殑璇彞鏃讹紝浣犲彲鑳戒細鐪嬭涓浜Duplicate column name璀﹀憡锛涗綘鍙互蹇界暐瀹冧滑銆
杩愯瀹岃剼鏈悗锛屽仠姝㈡湇鍔″櫒骞堕噸鍚
1. 鍚姩鍏抽棴杩涚▼
2. 鏈嶅姟鍣ㄦ牴鎹渶瑕佸垱寤哄叧闂嚎绋
3. 鏈嶅姟鍣ㄥ仠姝㈡帴鏀舵柊杩炴帴
4. 鏈嶅姟鍣ㄧ粓姝㈠綋鍓嶇殑娲诲姩
5. 瀛樺偍寮曟搸琚仠鎺夋垨鍏抽棴
6. 鏈嶅姟鍣ㄩ鍑
涓嬮潰鏄洿璇︾粏鐨勬弿杩帮細
1. 鍚姩鍏抽棴杩涚▼銆
鍙互鐢ㄥ绉嶆柟娉曞惎鍔ㄦ湇鍔″櫒鐨勫叧闂備緥濡傦紝鎷ユ湁SHUTDOWN鏉冮檺鐨勭敤鎴峰彲浠ユ墽琛mysqladmin shutdown鍛戒护銆mysqladmin鍙互鐢ㄤ簬鎵鏈夋敮鎸MySQL鐨勫钩鍙颁笂銆傚叾瀹冩搷浣滅郴缁熺浉鍏崇殑鍏抽棴寮濮嬫柟娉曡繕鍙兘鏈夛細鍦Unix涓紝褰撴帴鏀跺埌SIGTERM淇″彿鍚庯紝鏈嶅姟鍣ㄥ叧闂傚浜庡湪Windows涓綔涓烘湇鍔¤繍琛岀殑鏈嶅姟鍣紝褰撴湇鍔$鐞嗗櫒璁╁畠鍏抽棴鏃讹紝鍒欏叧闂
2. 鏈嶅姟鍣ㄦ牴鎹渶瑕佸垱寤哄叧闂嚎绋嬨
鏍规嵁寮濮嬪叧闂殑鏂瑰紡锛屾湇鍔″櫒鍙互鍒涘缓绾跨▼鏉ュ鐞嗗叧闂繘绋嬨傚鏋滃鎴风闇瑕佸叧闂紝鍒欏垱寤哄叧闂嚎绋嬨傚鏋滄敹鍒SIGTERM淇″彿鍚庡叧闂紝淇″彿绾跨▼鍙互鑷繁鍏抽棴锛屾垨鑰呭垱寤哄崟鐙殑绾跨▼鏉ュ畬鎴愩傚鏋滄湇鍔″櫒灏濊瘯鍒涘缓鍏抽棴绾跨▼鑰屼笉鑳藉垱寤(渚嬪锛屽鏋滃唴瀛樿鑰楀敖)锛屽畠鍦ㄩ敊璇棩蹇椾腑缁欏嚭璇婃柇娑堟伅锛
Error: Can't create thread to kill server
3. 鏈嶅姟鍣ㄥ仠姝㈡帴鏀舵柊杩炴帴銆
鍦ㄥ叧闂繃绋嬩腑瑕佹兂闃叉鍚姩鏂版椿鍔紝鏈嶅姟鍣ㄥ仠姝㈡帴鏀舵柊鐨勫鎴风杩炴帴銆傚畠灏嗗叧闂畠甯у惉鐨勭綉缁滆繛鎺ワ細TCP/IP绔彛銆Unix濂楁帴瀛楁枃浠躲Windows鍛藉悕绠¢亾鍜屽湪Windows涓殑鍏变韩鍐呭瓨銆
4. 鏈嶅姟鍣ㄧ粓姝㈠綋鍓嶇殑娲诲姩銆
瀵逛簬姣忎釜涓庡鎴风杩炴帴鐩稿叧鐨勭嚎绋嬶紝涓庡鎴风鐨勮繛鎺ヨ涓柇锛岀嚎绋嬭鏍囪涓衡滄潃鎺夌殑鈥濄傚綋绾跨▼娉ㄦ剰鍒版绫绘爣璁板悗鍒欑嚎绋嬬粓姝€傜┖闂茶繛鎺ョ殑绾跨▼寰堝揩缁堟銆傚綋鍓嶆澶勭悊鏌ヨ鐨勭嚎绋嬪畾鏈熸鏌ュ畠浠殑鐘舵侊紝缁堟鐨勬椂闂磋緝闀裤傚叧浜庣嚎绋嬬粓姝㈢殑璇︾粏淇℃伅锛屽弬瑙13.5.5.3鑺傦紝鈥淜ILL璇硶鈥锛岀壒鍒槸鍏充簬瀵MyISAM琛ㄧ殑鏉鎺夌殑REPAIR TABLE鎴OPTIMIZE TABLE鎿嶄綔銆
瀵逛簬鏈夋墦寮浜嬪姟鐨勭嚎绋嬶紝浜嬪姟琚洖婊氥傝娉ㄦ剰濡傛灉鏌愪釜绾跨▼姝e湪鏇存柊闈炰簨鍔¤〃锛屽琛UPDATE鎴INSERT绛夋搷浣滀細浣胯〃閮ㄥ垎鏇存柊锛屽洜涓烘搷浣滃湪瀹屾垚鍓嶄細缁堟銆
濡傛灉鏈嶅姟鍣ㄦ槸涓诲鍒舵湇鍔″櫒锛屼笌褰撳墠杩炴帴鐨勪粠鏈嶅姟鍣ㄧ浉鍏崇殑绾跨▼鐨勫鐞嗘柟寮忓悓鍏跺畠瀹㈡埛绔嚎绋嬨傚嵆姣忎釜绾跨▼琚爣璁颁负鏉鎺夌殑锛屽湪涓嬫妫鏌ヤ粬鐨勭姸鎬佸悗浼氶鍑恒
濡傛灉鏈嶅姟鍣ㄦ槸浠庡鍒舵湇鍔″櫒锛屽湪瀹㈡埛绔嚎绋嬫爣璁颁负鏉鎺夌殑涔嬪墠锛屾縺娲荤殑I/O鍜SQL绾跨▼琚仠姝€SQL绾跨▼鍏佽鍏堢粨鏉熷畠褰撳墠鐨勮鍙(浠ラ伩鍏嶉犳垚澶嶅埗闂)鐒跺悗鍋滄銆傚鏋滄鏃SQL绾跨▼姝d綅浜庝簨鍔′腑閮紝浜嬪姟鍒 鍥炴粴銆
5. 瀛樺偍寮曟搸琚仠鎺夋垨鍏抽棴銆
鍦ㄨ闃舵锛岃〃缂撳瓨琚竻绌猴紝鎵鏈夋墦寮鐨勮〃琚叧闂
姣忎釜瀛樺偍寮曟搸鎵ц瀹冪鐞嗙殑琛ㄩ渶瑕佺殑浠讳綍鍔ㄤ綔銆備緥濡傦紝MyISAM娓呯┖浠讳綍鎸傝捣鐨勮〃绱㈠紩鍐欐搷浣溿InnoDB灏嗗畠鐨勭紦鍐叉睜娓呯┖鍒扮‖鐩樹笂锛堥櫎闈innodb_fast_shutdown涓2锛夛紝灏嗗綋鍓嶇殑LSN鍐欏叆琛ㄥ唴锛屽苟缁堟鑷繁鐨勫唴閮ㄧ嚎绋嬨
6. 鏈嶅姟鍣ㄩ鍑恒
鏈妭鎻忚堪涓浜涘父瑙佺殑闇瑕佹敞鎰忕殑瀹夊叏闂锛屼互鍙婁竴浜涘彲浠ヤ娇浣犵殑MySQL瀹夎鏇村姞瀹夊叏浠ラ槻姝㈤粦瀹㈠拰璇敤鐨勬帾鏂姐傚叧浜MySQL鐢ㄤ簬璁剧疆鐢ㄦ埛璐︽埛骞舵鏌ユ暟鎹簱璁块棶鐨勮闂帶鍒剁郴缁熺殑鍏蜂綋淇℃伅锛屽弬瑙5.7鑺傦紝鈥淢ySQL璁块棶鏉冮檺绯荤粺鈥銆
浠讳綍鍦ㄤ笌Internet鑱旂綉鐨勮绠楁満涓婁娇鐢MySQL鐨勭敤鎴烽兘搴斾粩缁嗛槄璇绘湰鑺傦紝浠ラ伩鍏嶆渶甯歌鐨勫畨鍏ㄩ棶棰樸
璁ㄨ瀹夊叏鏃讹紝鎴戜滑寮鸿皟蹇呴』瀹屽叏淇濇姢鏁翠釜鏈嶅姟鍣ㄤ富鏈虹殑瀹夊叏(鑰屼笉鍙槸MySQL鏈嶅姟鍣)闃茶寖鍚勭绫诲瀷鐨勫彲鑳界殑鏀诲嚮锛氬伔鍚佷慨鏀广侀噸鏀惧拰鎷掔粷鏈嶅姟銆傛垜浠湪杩欓噷涓嶈兘瑕嗙洊鍚勬柟闈㈢殑鍐呭鍜屾帾鏂姐
MySQL鏍规嵁璁块棶鎺у埗鍒楄〃(ACL)瀵规墍鏈夎繛鎺ャ佹煡璇㈠拰鍏跺畠鐢ㄦ埛灏濊瘯鎵ц鐨勬搷浣滆繘琛屽畨鍏ㄧ鐞嗐MySQL瀹㈡埛绔拰鏈嶅姟鍣ㄤ箣闂磋繕鏀寔SSL-鍔犲瘑杩炴帴銆傝繖鍎胯璁虹殑璁稿姒傚康骞朵笉鏄MySQL涓撴湁鐨勶紱璇ユ濇兂鍑犱箮鍚屾牱閫傚悎鎵鏈夊簲鐢ㄧ▼搴忋
杩愯MySQL鏃讹紝搴斿敖閲忛伒浠庝笅闈㈢殑鎸囧锛
路 涓嶈璁╀换浣曚汉(闄や簡MySQL root璐︽埛)璁块棶mysql鏁版嵁搴撲腑鐨user琛紒杩欏緢鍏抽敭銆鍔犲瘑鐨勫瘑鐮佹墠鏄MySQL涓殑鐪熸鐨勫瘑鐮併鐭ラ亾user琛ㄤ腑鎵鍒楃殑瀵嗙爜骞朵笖鑳借闂璐︽埛瀹㈣闂殑涓绘満鐨勪汉鍙互寰堝鏄撳湴鐢ㄨ鐢ㄦ埛鐧诲綍銆
路 瀛︿範MySQL璁块棶鏉冮檺绯荤粺銆傜敤GRANT鍜REVOKE璇彞鏉ユ帶鍒跺MySQL鐨勮闂備笉瑕佹巿浜堣秴杩囬渶姹傜殑鏉冮檺銆傚喅涓嶈兘涓烘墍鏈変富鏈烘巿鏉冦
妫鏌ユ竻鍗曪細
o 璇曡瘯mysql -u root銆傚鏋滀綘鑳藉鎴愬姛杩炴帴鏈嶅姟鍣ㄨ屾病鏈夎浠讳綍瀵嗙爜锛屽垯璇存槑鏈夐棶棰樸備换浣曚汉鍙互浣滀负MySQLroot鐢ㄦ埛鐢ㄥ畠鐨勫叏閮ㄦ潈闄愭潵杩炴帴MySQL鏈嶅姟鍣紒鏌ラ槄MySQL瀹夎璇存槑锛屽簲鐗瑰埆娉ㄦ剰鍏充簬璁剧疆root瀵嗙爜鐨勪俊鎭傚弬瑙2.9.3鑺傦紝鈥滀娇鍒濆MySQL璐︽埛瀹夊叏鈥銆
o 閫氳繃SHOW GRANTS璇彞妫鏌ユ煡鐪嬭皝宸茬粡璁块棶浜嗕粈涔堛傜劧鍚庝娇鐢REVOKE璇彞鍒犻櫎涓嶅啀闇瑕佺殑鏉冮檺銆
路 涓嶈灏嗙函鏂囨湰瀵嗙爜淇濆瓨鍒版暟鎹簱涓傚鏋滀綘鐨勮绠楁満鏈夊畨鍏ㄥ嵄闄╋紝鍏ヤ镜鑰呭彲浠ヨ幏寰楁墍鏈夌殑瀵嗙爜骞朵娇鐢ㄥ畠浠傜浉鍙嶏紝搴斾娇鐢MD5()銆SHA1()鎴栧崟鍚戝搱甯屽嚱鏁般
路 涓嶈浠庤瘝鍏镐腑閫夋嫨瀵嗙爜銆傛湁涓撻棬鐨勭▼搴忓彲浠ョ牬瑙e畠浠傚嵆浣胯薄鈥xfish98鈥濊繖鏍风殑瀵嗙爜涔熷緢宸傝屸duag98鈥濊濂藉緱澶氾紝铏界劧鍖呭惈浜嗙浉鍚岀殑瀛椻fish鈥濓紝浣嗕粠鏍囧噯QWERTY閿洏鍚戝乏杈撳叆銆傚彟涓绉嶆柟娉曟槸浣跨敤鈥Mhall鈥濓紝鏉ヨ嚜鍙ュ瓙鈥Mary had a little lamb.鈥濅腑姣忎釜瀛楃殑绗竴涓瓧绗︺傝繖鏍峰緢瀹规槗璁颁綇骞惰緭鍏ワ紝浣嗘槸涓嶇煡閬撶殑浜哄緢闅剧寽鍑烘潵銆
路 璐拱闃茬伀澧欍傝繖鏍峰彲浠ヤ繚鎶や綘闃茶寖鍚勭杞欢涓嚦灏50%鐨勫悇绉嶇被鍨嬬殑鏀诲嚮銆傛妸MySQL鏀惧埌闃茬伀澧欏悗鎴栭殧绂诲尯(DMZ)銆
妫鏌ユ竻鍗曪細
o 璇曡瘯浠Internet浣跨敤nmap宸ュ叿鎵弿绔彛銆MySQL榛樿浣跨敤绔彛3306銆備笉搴斾粠涓嶅彲淇′换涓绘満璁块棶璇ョ鍙c傚彟涓绉嶆鏌ユ槸鍚MySQL绔彛鎵撳紑鐨勭畝鍗曟柟寮忔槸浠庤繙绋嬫満鍣ㄨ瘯璇曚笅闈㈢殑鍛戒护锛屽叾涓server_host鏄MySQL鏈嶅姟鍣ㄨ繍琛岀殑涓绘満锛
o shell> telnet server_host 3306
濡傛灉寰楀埌杩炴帴骞跺緱鍒颁竴浜涘瀮鍦惧瓧绗︼紝鍒欑鍙f墦寮鐫锛屽垯搴斾粠闃茬伀澧欐垨璺敱鍣ㄤ笂鍏抽棴锛岄櫎闈炰綘鏈夊悎鐞嗙殑鐞嗙敱璁╁畠寮鐫銆傚鏋telnet鎸傝捣鎴栬繛鎺ヨ鎷掔粷锛屽垯绔彛琚樆濉烇紝杩欐槸浣犳墍甯屾湜鐨勩
涓嶈淇′换搴旂敤绋嬪簭鐨勭敤鎴疯緭鍏ョ殑浠讳綍鏁版嵁銆傚畠浠彲浠ョ敤Web褰㈠紡銆URL鎴栨瀯寤虹殑搴旂敤绋嬪簭杈撳叆鐗规畩鎴栭冩孩瀛楃搴忓垪鏉ュ皾璇曟楠椾綘鐨勪唬鐮併傚鏋滄煇涓敤鎴疯緭鍏モ; DROP DATABASE mysql;鈥濈瓑鍐呭锛屽簲纭繚浣犵殑搴旂敤绋嬪簭淇濇寔瀹夊叏銆傝繖鏄壒渚嬶紝浣嗗綋榛戝浣跨敤绫讳技鎶鏈椂锛屽鏋滀綘娌℃湁鍋氬ソ鍑嗗锛岀粨鏋滃彲鑳戒細鍑虹幇澶х殑瀹夊叏婕忔礊鍜屾暟鎹涪澶便
涓涓父瑙佺殑閿欒鏄彧淇濇姢瀛楃涓叉暟鎹笺備竴瀹氳璁颁綇杩樺簲妫鏌ユ暟瀛楁暟鎹傚鏋滃綋鐢ㄦ埛杈撳叆鍊234鏃讹紝搴旂敤绋嬪簭鐢熸垚鏌ヨSELECT * FROM table WHERE ID=234锛鐢ㄦ埛鍙互杈撳叆鍊234 OR 1=1浣垮簲鐢ㄧ▼搴忕敓鎴愭煡璇SELECT * FROM table WHERE ID=234 OR 1=1銆傜粨鏋滄槸鏈嶅姟鍣ㄦ煡鎵捐〃鍐呯殑姣忎釜璁板綍銆傝繖鏍蜂細鏆撮湶姣忎釜璁板綍骞堕犳垚杩囧鐨勬湇鍔″櫒璐熻浇銆備繚鎶ら槻鑼冭繖绫绘敾鍑荤殑鏈绠鍗曠殑鏂规硶鏄娇鐢ㄥ崟寮曞彿灏嗘暟瀛楀父閲忓紩璧锋潵锛SELECT * FROM table WHERE ID='234'銆傚鏋滅敤鎴疯緭鍏ュ叾瀹冧俊鎭紝鍧囧彉涓哄瓧绗︿覆鐨勪竴閮ㄥ垎銆傚湪鏁板瓧閮ㄥ垎锛MySQL鑷姩灏嗗瓧绗︿覆杞崲涓烘暟瀛楀苟鍓ョ瀛楃涓插寘鍚殑闄勫姞鐨勯潪鏁板瓧瀛楃銆
鏈夋椂鍊欎汉浠細璁や负濡傛灉鏁版嵁搴撳彧鍖呭惈渚涘叕鍏变娇鐢ㄧ殑鏁版嵁锛屽垯涓嶉渶瑕佷繚鎶ゃ傝繖鏄笉姝g‘鐨勩傚嵆浣垮厑璁告樉绀烘暟鎹簱涓殑浠讳綍璁板綍锛屼綘浠嶇劧搴斾繚鎶ら槻鑼冩嫆缁濇湇鍔℃敾鍑(渚嬪锛屽熀浜庡墠闈㈡钀戒腑鎵杩扮殑鎶鏈殑鏀诲嚮锛屼細浣挎湇鍔″櫒娴垂璧勬簮)銆傚惁鍒欙紝浣犵殑鏈嶅姟鍣ㄤ笉鍐嶅搷搴斿悎娉曠敤鎴枫
妫鏌ユ竻鍗曪細
o 璇曡瘯鐢Web褰㈠紡杈撳叆鍗曞紩鍙峰拰鍙屽紩鍙(鈥'鈥欏拰鈥"鈥)銆傚鏋滃緱鍒颁换浣曞舰寮忕殑MySQL閿欒锛岀珛鍗冲垎鏋愬師鍥犮
o 璇曡瘯淇敼鍔ㄦURL锛屽彲浠ュ湪鍏朵腑娣诲姞%22(鈥"鈥)銆%23(鈥#鈥)鍜%27(鈥'鈥)銆
o 璇曡瘯鍦ㄥ姩鎬URL涓慨鏀规暟鎹被鍨嬶紝浣跨敤鍓嶉潰绀轰緥涓殑瀛楃锛屽寘鎷暟瀛楀拰瀛楃绫诲瀷銆備綘鐨勫簲鐢ㄧ▼搴忓簲瓒冲瀹夊叏锛屽彲浠ラ槻鑼冩绫讳慨鏀瑰拰绫讳技鏀诲嚮銆
o 璇曡瘯杈撳叆瀛楃銆佺┖鏍煎拰鐗规畩绗﹀彿锛屼笉瑕佽緭鍏ユ暟鍊煎瓧娈电殑鏁板瓧銆備綘鐨勫簲鐢ㄧ▼搴忓簲鍦ㄥ皢瀹冧滑浼犻掑埌MySQL涔嬪墠灏嗗畠浠垹闄ゆ垨鐢熸垚閿欒銆傚皢鏈粡杩囨鏌ョ殑鍊间紶閫掔粰MySQL鏄緢鍗遍櫓鐨勶紒
o 灏嗘暟鎹紶缁MySQL涔嬪墠鍏堟鏌ュ叾澶у皬銆
o 鐢ㄧ鐞嗚处鎴蜂箣澶栫殑鐢ㄦ埛鍚嶅皢搴旂敤绋嬪簭杩炴帴鍒版暟鎹簱銆備笉瑕佺粰搴旂敤绋嬪簭浠讳綍涓嶉渶瑕佺殑璁块棶鏉冮檺銆
路 璁稿搴旂敤绋嬪簭缂栫▼鎺ュ彛鎻愪緵浜嗘帾鏂介冮告暟鎹间腑鐨勭壒娈婂瓧绗︺傚鏋滀娇鐢ㄦ纭紝鍙互闃叉搴旂敤绋嬪簭鐢ㄦ埛杈撳叆浣垮簲鐢ㄧ▼搴忕敓鎴愪笉鏈熸湜鐨勬晥鏋滅殑璇彞鐨勬暟鍊硷細
o MySQL C API锛氫娇鐢mysql_real_escape_string() API璋冪敤銆
o MySQL++锛氭煡璇㈡祦浣跨敤escape鍜quote淇绗︺
o PHP锛氫娇鐢mysql_escape_string()鍑芥暟鍩轰簬MySQL C API涓殑鍚屽悕鍑芥暟銆(鍦PHP 4.0.3涔嬪墠,浣跨敤addslashes()锛銆鍦PHP 5涓,鍙互浣跨敤mysqli鎵╁睍鍚嶏紝瀹冩敮鎸佹敼杩涚殑MySQL閴村畾鍗忚鍜屽瘑鐮侊紝浠ュ強鐢ㄥ崰浣嶇缂栧啓鐨勮鍙ャ
o Perl DBI锛氫娇鐢quote()鏂规硶鎴栦娇鐢ㄥ崰浣嶇銆
o Java JDBC锛氫娇鐢ㄤ竴涓PreparedStatement瀵硅薄鍜屽崰浣嶇銆
鍏跺畠缂栫▼鎺ュ彛鏈夌被浼肩殑鍔熻兘銆
路 涓嶈閫氳繃Internet浼犻佹槑鏂(鏈姞瀵嗙殑)鏁版嵁銆傝淇℃伅鍙互琚湁瓒冲鏃堕棿鍜岃兘鍔涙潵鎴彇瀹冨苟鐢ㄤ簬涓汉鐩殑鐨勪换浣曚汉璁块棶銆傜浉鍙嶏紝搴斾娇鐢ㄥ姞瀵嗗崗璁紝渚嬪SSL鎴SSH銆MySQL鏀寔鍐呴儴SSL杩炴帴锛屼緥濡傜増鏈 4.0.0銆傚彲浠ヤ娇鐢SSH绔彛鏄犲皠涓洪氫俊鍒涘缓鍔犲瘑(骞跺帇缂)鐨勯毀閬撱
路 瀛︿細浣跨敤tcpdump鍜strings宸ュ叿銆傚湪澶у鏁版儏鍐典笅锛屼綘鍙互浣跨敤涓嬮潰鐨勫懡浠ゆ鏌ユ槸鍚MySQL鏁版嵁娴佹湭鍔犲瘑锛
路 shell> tcpdump -l -i eth0 -w - src or dst port 3306 | strings
(璇ュ懡浠ゅ湪Linux涓彲浠ュ伐浣滐紝鍦ㄥ叾瀹冪郴缁熶腑缁忚繃灏忓皬鐨勪慨鏀瑰悗搴斿彲浠ュ伐浣滐級銆 璀﹀憡锛氬鏋滀綘娌℃湁鐪嬭鏄庢枃鏁版嵁锛屽苟涓嶄竴瀹氳鏄庝俊鎭疄闄呬笂琚姞瀵嗕簡銆傚鏋滀綘闇瑕佽緝楂樼骇鍒殑瀹夊叏锛屼綘搴斿挩璇㈠畨鍏ㄤ笓瀹躲
褰撲綘杩炴帴鍒MySQL鏈嶅姟鍣ㄦ椂锛屼綘搴斾娇鐢ㄤ竴涓瘑鐮併傚瘑鐮佷笉浠ユ槑鏂囧湪涓婁紶杈撱傚鎴风杩炴帴搴忓垪涓殑瀵嗙爜澶勭悊鍦MySQL 4.1.1涓凡缁忓崌绾э紝寰堝畨鍏ㄣ傚鏋滀綘浠嶇劧浣跨敤pre-4.1.1-椋庢牸鐨勫瘑鐮侊紝鍔犲瘑绠楁硶涓嶅鏂扮畻娉曞己锛涢氳繃涓浜涘伐浣滐紝鍙互绐冨彇瀹㈡埛绔拰鏈嶅姟鍣ㄤ箣闂寸殑閫氫俊鐨勮仾鏄庣殑鏀诲嚮鑰呭彲浠ョ牬瑙e瘑鐮併(鍏充簬涓嶅悓鐨勫瘑鐮佸鐞嗘柟娉曠殑璁ㄨ鍙傝5.7.9鑺傦紝鈥淢ySQL 4.1涓殑瀵嗙爜鍝堝笇澶勭悊鈥锛銆 濡傛灉瀹㈡埛绔拰鏈嶅姟鍣ㄤ箣闂寸殑杩炴帴閫氳繃涓嶅彲淇′换缃戠粶锛屼綘搴斾娇鐢SSH闅ч亾鏉ュ姞瀵嗛氫俊銆
鎵鏈夊叾瀹冧俊鎭互鏂囨湰浼犻侊紝鍙互琚彲浠ョ湅鍒拌繛鎺ョ殑浠讳綍浜鸿鍙栥傚鏋滀綘鎷呭績杩欎釜锛屼綘鍙互浣跨敤鍘嬬缉鍗忚鏉ヤ娇閫氫俊鏇撮毦浠ヨВ瀵嗐傝鎯充娇杩炴帴鏇村姞瀹夊叏锛屼綘搴斾娇鐢SSH鏉ヨ幏寰楀姞瀵嗙殑MySQL鏈嶅姟鍣ㄥ拰MySQL瀹㈡埛绔箣闂寸殑TCP/IP杩炴帴銆備綘鍙互浠http://www.openssh.org/鎵惧埌寮鏀炬簮鐮SSH 瀹㈡埛绔紝骞跺彲浠ヤ粠http://www.ssh.com/鑾峰緱鍟嗕笟SSH瀹㈡埛绔
浣犺繕鍙互浣跨敤MySQL鍐呴儴OpenSSL鏀寔銆傚弬瑙5.8.7鑺傦紝鈥滀娇鐢ㄥ畨鍏ㄨ繛鎺モ銆
涓轰簡浣MySQL绯荤粺瀹夊叏锛屽己鐑堣姹備綘鑰冭檻涓嬪垪寤鸿锛
路 瀵规墍鏈MySQL鐢ㄦ埛浣跨敤瀵嗙爜銆傚鎴风绋嬪簭涓嶉渶瑕佺煡閬撹繍琛屽畠鐨勪汉鍛樼殑韬唤銆傚浜庡鎴风/鏈嶅姟鍣ㄥ簲鐢ㄧ▼搴忥紝鐢ㄦ埛鍙互鎸囧畾瀹㈡埛绔▼搴忕殑鐢ㄦ埛鍚嶃備緥濡傦紝濡傛灉other_user娌℃湁瀵嗙爜锛屼换浣曚汉鍙互绠鍗曞湴鐢mysql -u other_user db_name鍐掑厖浠栦汉璋冪敤mysql绋嬪簭杩涜杩炴帴銆傚鏋滄墍鏈夌敤鎴锋湁瀵嗙爜锛屼娇鐢ㄥ叾瀹冪敤鎴风殑璐︽埛杩涜杩炴帴瑕佸洶闅惧緱澶氥
瑕佹兂鏇存敼鐢ㄦ埛鐨勫瘑鐮侊紝搴斾娇鐢SET PASSWORD璇彞銆傝繕鍙互鐩存帴鏇存柊mysql鏁版嵁搴撲腑鐨user琛ㄣ備緥濡傦紝瑕佹洿鏀规墍鏈root鐢ㄦ埛鐨MySQL璐︽埛鐨勫瘑鐮侊紝搴旓細
shell> mysql -u root
mysql> UPDATE mysql.user SET Password=PASSWORD('newpwd')
-> WHERE User='root';
mysql> FLUSH PRIVILEGES;
路 缁濆涓嶈浣滀负Unix鐨root鐢ㄦ埛杩愯MySQL鏈嶅姟鍣ㄣ傝繖鏍峰仛闈炲父鍗遍櫓锛屽洜涓轰换浣曞叿鏈FILE鏉冮檺鐨勭敤鎴疯兘澶熺敤root鍒涘缓鏂囦欢(渚嬪锛~root/.bashrc)銆備负浜嗛槻姝紝mysqld鎷掔粷鐢root杩愯锛岄櫎闈炰娇鐢--user=root閫夐」鏄庢樉鎸囧畾銆
搴斿彲浠(骞朵笖搴旇)鐢ㄦ櫘閫氶潪鐗规潈鐢ㄦ埛杩愯mysqld銆備綘鍙互鍒涘缓鐙珛鐨Unix涓殑mysql璐︽埛鏉ヤ互渚夸娇鎵鏈夊唴瀹规洿鍔犲畨鍏ㄣ傝璐︽埛鍙敤浜庣鐞MySQL銆傝鎯崇敤鍏跺畠Unix鐢ㄦ埛鍚姩mysqld锛屽鍔user閫夐」鎸囧畾/etc/my.cnf閫夐」鏂囦欢鎴栨湇鍔″櫒鏁版嵁鐩綍鐨my.cnf閫夐」鏂囦欢涓殑[mysqld]缁勭殑鐢ㄦ埛鍚嶃備緥濡傦細
[mysqld]
user=mysql
璇ュ懡浠や娇鏈嶅姟鍣ㄧ敤鎸囧畾鐨勭敤鎴锋潵鍚姩锛屾棤璁轰綘鎵嬪姩鍚姩鎴栭氳繃mysqld_safe鎴mysql.server鍚姩銆傝缁嗕俊鎭弬瑙A.3.2鑺傦紝鈥滃浣曚互鏅氱敤鎴疯韩浠借繍琛孧ySQL鈥銆
浣滀负鍏跺畠Unix鐢ㄦ埛鑰屼笉鐢root杩愯mysqld锛屼綘涓嶉渶瑕佹洿鏀user琛ㄤ腑鐨root鐢ㄦ埛鍚嶏紝鍥犱负MySQL璐︽埛鐨勭敤鎴峰悕涓Unix璐︽埛鐨勭敤鎴峰悕鏃犲叧銆
路 涓嶈鍏佽浣跨敤琛ㄧ殑绗﹀彿閾炬帴銆(鍙互鐢--skip-symbolic-links閫夐」绂佺敤锛銆濡傛灉浣犵敤root杩愯mysqld鍒欑壒鍒噸瑕侊紝鍥犱负浠讳綍瀵规湇鍔″櫒鐨勬暟鎹洰褰曟湁鍐欒闂潈闄愮殑浜哄垯鑳藉鍒犻櫎绯荤粺涓殑浠讳綍鏂囦欢锛佸弬瑙7.6.1.2鑺傦紝鈥滃湪Unix骞冲彴涓婁娇鐢ㄨ〃鐨勭鍙烽摼鎺鈥濄
路 纭繚mysqld杩愯鏃讹紝鍙娇鐢ㄥ鏁版嵁搴撶洰褰曞叿鏈夎鎴栧啓鏉冮檺鐨Unix鐢ㄦ埛鏉ヨ繍琛屻
路 涓嶈灏PROCESS鎴SUPER鏉冮檺鎺堢粰闈炵鐞嗙敤鎴枫mysqladmin processlist鐨勮緭鍑烘樉绀哄嚭褰撳墠鎵ц鐨勬煡璇㈡鏂囷紝濡傛灉鍙﹀鐨勭敤鎴峰彂鍑轰竴涓UPDATE user SET password=PASSWORD('not_secure')鏌ヨ锛岃鍏佽鎵ц閭d釜鍛戒护鐨勪换浣曠敤鎴峰彲鑳界湅寰楀埌銆
mysqld涓烘湁SUPER鏉冮檺鐨勭敤鎴蜂笓闂ㄤ繚鐣欎竴涓澶栫殑杩炴帴锛屽洜姝ゅ嵆浣挎墍鏈夋櫘閫氳繛鎺ヨ鍗犵敤锛MySQL root鐢ㄦ埛浠嶅彲浠ョ櫥褰曞苟妫鏌ユ湇鍔″櫒鐨勬椿鍔ㄣ
鍙互浣跨敤SUPER鏉冮檺鏉ョ粓姝㈠鎴风杩炴帴锛岄氳繃鏇存敼绯荤粺鍙橀噺鐨勫兼洿鏀规湇鍔$殑鍣ㄦ搷浣滐紝骞舵帶鍒跺鍒舵湇鍔″櫒銆
路 涓嶈鍚戦潪绠$悊鐢ㄦ埛鎺堜簣FILE鏉冮檺銆傛湁杩欐潈闄愮殑浠讳綍鐢ㄦ埛鑳藉湪鎷ユ湁mysqld瀹堟姢杩涚▼鏉冮檺鐨勬枃浠剁郴缁熼偅閲屽啓涓涓枃浠讹紒涓轰簡鏇村姞瀹夊叏锛岀敱SELECT ... INTO OUTFILE鐢熸垚鐨勬墍鏈夋枃浠跺姣忎釜浜烘槸鍙啓鐨勶紝骞朵笖浣犱笉鑳借鐩栧凡缁忓瓨鍦ㄧ殑鏂囦欢銆
file鏉冮檺涔熷彲浠ヨ鐢ㄦ潵璇诲彇浠讳綍浣滀负杩愯鏈嶅姟鍣ㄧ殑Unix鐢ㄦ埛鍙鍙栨垨璁块棶鐨勬枃浠躲備娇鐢ㄨ鏉冮檺锛屼綘鍙互灏嗕换浣曟枃浠惰鍏ユ暟鎹簱琛ㄣ傝繖鍙兘琚互鐢紝渚嬪锛岄氳繃浣跨敤LOAD DATA瑁呰浇鈥/etc/passwd鈥杩涗竴涓暟鎹簱琛紝鐒跺悗鑳界敤SELECT鏄剧ず瀹銆
路 濡傛灉浣犱笉淇′换浣犵殑DNS锛屼綘搴旇鍦ㄦ巿鏉冭〃涓娇鐢IP鏁板瓧鑰屼笉鏄富鏈哄悕銆傚湪浠讳綍鎯呭喌涓嬶紝浣犲簲璇ラ潪甯稿皬蹇冨湴浣跨敤鍖呭惈閫氶厤绗︾殑涓绘満鍚嶆潵鍒涘缓 鎺堟潈琛ㄦ潯鐩紒
路 濡傛灉浣犳兂瑕侀檺鍒跺崟涓处鎴峰厑璁哥殑杩炴帴鏁伴噺锛屼綘鍙互璁剧疆mysqld涓殑max_user_connections鍙橀噺鏉ュ畬鎴愩GRANT璇彞涔熷彲浠ユ敮鎸 璧勬簮鎺у埗閫夐」鏉ラ檺鍒舵湇鍔″櫒瀵逛竴涓处鎴峰厑璁哥殑浣跨敤鑼冨洿銆傚弬瑙13.5.1.3鑺傦紝鈥淕RANT鍜孯EVOKE璇硶鈥銆
涓嬪垪mysqld閫夐」褰卞搷瀹夊叏锛
路 --allow-suspicious-udfs
璇ラ夐」鎺у埗鏄惁鍙互杞藉叆涓诲嚱鏁板彧鏈xxx绗︾殑鐢ㄦ埛瀹氫箟鍑芥暟銆傞粯璁ゆ儏鍐典笅锛岃閫夐」琚叧闂紝骞朵笖鍙兘杞藉叆鑷冲皯鏈夎緟鍔╃鐨UDF銆傝繖鏍峰彲浠ラ槻姝粠鏈寘鍚悎娉UDF鐨勫叡浜璞℃枃浠惰浇鍏ュ嚱鏁般傚弬瑙27.2.3.6鑺傦紝鈥滅敤鎴峰畾涔夊嚱鏁板畨鍏ㄦ敞鎰忎簨椤光銆
路 --local-infile[={0|1}]
濡傛灉鐢--local-infile=0鍚姩鏈嶅姟鍣锛鍒欏鎴风涓嶈兘浣跨敤LOCAL
in LOAD DATA璇彞銆傚弬瑙5.6.4鑺傦紝鈥淟OAD DATA LOCAL瀹夊叏闂鈥銆
路 --old-passwords
寮哄埗鏈嶅姟鍣ㄤ负鏂板瘑鐮佺敓鎴愮煭(pre-4.1)瀵嗙爜鍝堝笇銆傚綋鏈嶅姟鍣ㄥ繀椤绘敮鎸佹棫鐗堟湰瀹㈡埛绔▼搴忔椂锛屼负浜嗕繚璇佸吋瀹规ц繖寰堟湁鐢ㄣ傚弬瑙5.7.9鑺傦紝鈥淢ySQL 4.1涓殑瀵嗙爜鍝堝笇澶勭悊鈥銆
路 (OBSOLETE) --safe-show-database
鍦ㄤ互鍓嶇増鏈殑MySQL涓紝璇ラ夐」浣SHOW DATABASES璇彞鍙樉绀虹敤鎴峰叿鏈夐儴鍒嗘潈闄愮殑鏁版嵁搴撳悕銆傚湪MySQL 5.1涓紝璇ラ夐」涓嶅啀浣滀负鐜板湪鐨 榛樿琛屼负浣跨敤锛屾湁涓涓SHOW DATABASES鏉冮檺鍙互鐢ㄦ潵鎺у埗姣忎釜璐︽埛瀵规暟鎹簱鍚嶇殑璁块棶銆傚弬瑙13.5.1.3鑺傦紝鈥淕RANT鍜孯EVOKE璇硶鈥銆
路 --safe-user-create
濡傛灉鍚敤锛岀敤鎴蜂笉鑳界敤GRANT璇彞鍒涘缓鏂扮敤鎴凤紝闄ら潪鐢ㄦ埛鏈mysql.user琛ㄧ殑INSERT鏉冮檺銆傚鏋滀綘鎯宠鐢ㄦ埛鍏锋湁鎺堟潈鏉冮檺鏉ュ垱寤烘柊鐢ㄦ埛锛屼綘搴旂粰鐢ㄦ埛鎺堜簣涓嬮潰鐨勬潈闄愶細
mysql> GRANT INSERT(user) ON mysql.user TO 'user_name'@'host_name';
杩欐牱纭繚鐢ㄦ埛涓嶈兘鐩存帴鏇存敼鏉冮檺鍒楋紝蹇呴』浣跨敤GRANT璇彞缁欏叾瀹冪敤鎴锋巿浜堣鏉冮檺銆
路 --secure-auth
涓嶅厑璁搁壌瀹氭湁鏃(pre-4.1)瀵嗙爜鐨勮处鎴枫
路 --skip-grant-tables
杩欎釜閫夐」瀵艰嚧鏈嶅姟鍣ㄦ牴鏈笉浣跨敤鏉冮檺绯荤粺銆傝繖缁欐瘡涓汉浠瀹屽叏璁块棶鎵鏈夌殑鏁版嵁搴撶殑鏉冨姏锛侊紙閫氳繃鎵цmysqladmin flush-privileges鎴mysqladmin reload鍛戒护锛屾垨鎵цFLUSH PRIVILEGES璇彞锛屼綘鑳藉憡璇変竴涓鍦ㄨ繍琛岀殑鏈嶅姟鍣ㄥ啀娆″紑濮嬩娇鐢ㄦ巿鏉冭〃銆傦級
路 --skip-name-resolve
涓绘満鍚嶄笉琚В鏋愩傛墍鏈夊湪鎺堟潈琛ㄧ殑Host鐨勫垪鍊煎繀椤绘槸IP鍙锋垨localhost銆
路 --skip-networking
鍦ㄧ綉缁滀笂涓嶅厑璁TCP/IP杩炴帴銆傛墍鏈夊埌mysqld鐨勮繛鎺ュ繀椤荤粡鐢Unix濂楁帴瀛楄繘琛屻
路 --skip-show-database
浣跨敤璇ラ夐」锛屽彧鍏佽鏈SHOW DATABASES鏉冮檺鐨勭敤鎴锋墽琛SHOW DATABASES璇彞锛岃璇彞鏄剧ず鎵鏈夋暟鎹簱鍚嶃備笉浣跨敤璇ラ夐」锛屽厑璁告墍鏈夌敤鎴锋墽琛SHOW DATABASES锛屼絾鍙樉绀虹敤鎴锋湁SHOW DATABASES鏉冮檺鎴栭儴鍒嗘暟鎹簱鏉冮檺鐨勬暟鎹簱鍚嶃傝娉ㄦ剰鍏ㄥ眬鏉冮檺鎸囨暟鎹簱鐨勬潈闄愩
LOAD DATA璇彞鍙互瑁呰浇鏈嶅姟鍣ㄤ富鏈轰笂鐨勬枃浠讹紝鑻ユ寚瀹LOCAL鍏抽敭瀛楋紝鍙互瑁呰浇瀹㈡埛绔枃浠躲
鏀寔LOCAL鐗堟湰鐨LOAD DATA璇彞鏈変袱涓彲鑳界殑瀹夊叏闂锛
路 鐢MySQL鏈嶅姟鍣ㄥ惎鍔ㄦ枃浠朵粠瀹㈡埛绔悜鏈嶅姟鍣ㄤ富鏈虹殑浼犺緭銆傜悊璁轰笂锛屾墦杩囪ˉ涓佺殑鏈嶅姟鍣ㄥ彲浠ュ憡璇夊鎴风绋嬪簭浼犺緭鏈嶅姟鍣ㄩ夋嫨鐨勬枃浠讹紝鑰屼笉鏄鎴风敤LOAD DATA璇彞鎸囧畾鐨勬枃浠躲傝繖鏍锋湇鍔″櫒鍙互璁块棶瀹㈡埛绔笂瀹㈡埛鏈夎璁块棶鏉冮檺鐨勪换浣曟枃浠躲
路 鍦Web鐜涓紝瀹㈡埛浠Web鏈嶅姟鍣ㄨ繛鎺ワ紝鐢ㄦ埛鍙互浣跨敤LOAD DATA LOCAL鏉ヨ鍙Web鏈嶅姟鍣ㄨ繘绋嬫湁璇昏闂潈闄愮殑浠讳綍鏂囦欢(鍋囧畾鐢ㄦ埛鍙互杩愯SQL鏈嶅姟鍣ㄧ殑浠讳綍鍛戒护)銆傚湪杩欑鐜涓紝MySQL鏈嶅姟鍣ㄧ殑瀹㈡埛瀹為檯涓婃槸Web鏈嶅姟鍣紝鑰屼笉鏄繛鎺Web鏈嶅姟鍣ㄧ殑鐢ㄦ埛杩愯鐨勭▼搴忋
瑕佸鐞嗚繖浜涢棶棰橈紝鎴戜滑鏇存敼浜MySQL 3.23.49鍜MySQL 4.0.2(Windows涓殑4.0.13)涓殑LOAD DATA LOCAL鐨勫鐞嗘柟娉曪細
路 榛樿鎯呭喌涓嬶紝鐜板湪鎵鏈変簩杩涘埗鍒嗕腑鐨勫彂MySQL瀹㈡埛绔拰搴撴槸鐢--enable-local-infile閫夐」缂栬瘧锛屼互渚夸笌MySQL 3.23.48鍜屼互鍓嶇殑鐗堟湰鍏煎銆
路 濡傛灉浣犱粠婧愮爜鏋勫缓MySQL浣嗘病鏈変娇鐢--enable-local-infile閫夐」鏉ヨ繘琛configure锛屽垯瀹㈡埛涓嶈兘浣跨敤LOAD DATA LOCAL锛岄櫎闈炴樉寮忚皟鐢mysql_options (...MYSQL_OPT_鏈湴_INFILE锛0)銆傚弬瑙25.2.3.48鑺傦紝鈥渕ysql_options()鈥銆
路 浣犲彲浠ョ敤--local-infile=0閫夐」鍚姩mysqld浠庢湇鍔″櫒绔鐢ㄦ墍鏈LOAD DATA LOCAL鍛戒护銆
路 瀵逛簬mysql鍛戒护琛屽鎴风锛屽彲浠ラ氳繃鎸囧畾--local-infile[=1]閫夐」鍚敤LOAD DATA LOCAL锛屾垨閫氳繃--local-infile=0閫夐」绂佺敤銆傜被浼煎湴锛屽浜mysqlimport锛--local or -L閫夐」鍚敤鏈湴鏁版嵁鏂囦欢瑁呰浇銆傚湪浠讳綍鎯呭喌涓嬶紝鎴愬姛杩涜鏈湴瑁呰浇闇瑕佹湇鍔″櫒鍚敤鐩稿叧閫夐」銆
路 濡傛灉浣犱娇鐢LOAD DATA LOCAL Perl鑴氭湰鎴栧叾瀹冭閫夐」鏂囦欢涓殑[client]缁勭殑绋嬪簭锛屼綘鍙互鍦ㄧ粍鍐呮坊鍔local-infile=1閫夐」銆備絾鏄紝涓轰簡渚块潰涓嶇悊瑙local-infile鐨勭▼搴忎骇鐢熼棶棰橈紝鍒欒瀹氫娇鐢loose- prefix锛
路 [client]
路 loose-local-infile=1
路 濡傛灉LOAD DATA LOCAL INFILE鍦ㄦ湇鍔″櫒鎴栧鎴风琚鐢紝璇曞浘鎵ц璇ヨ鍙ョ殑瀹㈡埛绔皢鏀跺埌涓嬮潰鐨勯敊璇秷鎭細
ERROR 1148: The used command is not allowed with this MySQL version
MySQL鏉冮檺绯荤粺淇濊瘉鎵鏈夌殑鐢ㄦ埛鍙墽琛屽厑璁稿仛鐨勪簨鎯呫傚綋浣犺繛鎺MySQL鏈嶅姟鍣ㄦ椂锛屼綘鐨勮韩浠界敱浣犱粠閭e効杩炴帴鐨勪富鏈鍜浣犳寚瀹氱殑鐢ㄦ埛鍚鏉ュ喅瀹氥傝繛鎺ュ悗鍙戝嚭璇锋眰鍚庯紝绯荤粺鏍规嵁浣犵殑韬唤鍜浣犳兂鍋氫粈涔鏉ユ巿浜堟潈闄愩
MySQL鍦ㄨ瀹氳韩浠戒腑鑰冭檻浣犵殑涓绘満鍚嶅拰鐢ㄦ埛鍚嶅瓧锛屾槸鍥犱负鍑犱箮娌℃湁鍘熷洜鍋囧畾涓涓粰瀹氱殑鐢ㄦ埛鍦ㄥ洜鐗圭綉涓婂睘浜庡悓涓涓汉銆備緥濡傦紝浠office.com杩炴帴鐨勭敤鎴joe涓嶄竴瀹氬拰浠elsewhere.com杩炴帴鐨joe鏄悓涓涓汉銆MySQL閫氳繃鍏佽浣犲尯鍒嗗湪涓嶅悓鐨勪富鏈轰笂纰板阀鏈夊悓鏍峰悕瀛楃殑鐢ㄦ埛鏉ュ鐞嗗畠锛氫綘鍙互瀵joe浠office.com杩涜鐨勮繛鎺ユ巿涓庝竴涓潈闄愰泦锛岃屼负joe浠elsewhere.com鐨勮繛鎺ユ巿浜堜竴涓笉鍚岀殑鏉冮檺闆嗐
MySQL瀛樺彇鎺у埗鍖呭惈2涓樁娈碉細
濡傛灉杩炴帴鏃朵綘鐨勬潈闄愯鏇存敼浜(閫氳繃浣犲拰鍏跺畠浜)锛岃繖浜涙洿鏀逛笉涓瀹氱珛鍗冲浣犲彂鍑虹殑涓嬩竴涓鍙ョ敓鏁堛傝鎯呭弬瑙5.7.7鑺傦紝鈥滄潈闄愭洿鏀逛綍鏃剁敓鏁堚銆
鏈嶅姟鍣ㄥ湪mysql鏁版嵁搴撶殑 鎺堟潈琛ㄤ腑淇濆瓨鏉冮檺淇℃伅(鍗冲湪mysql鏁版嵁搴撲腑)銆傚綋MySQL鏈嶅姟鍣ㄥ惎鍔ㄦ椂灏嗚繖浜涜〃鐨勫唴瀹硅鍏ュ唴瀛橈紝鍦5.7.7鑺傦紝鈥滄潈闄愭洿鏀逛綍鏃剁敓鏁堚鐨勭幆澧冧笅閲嶆柊璇诲彇瀹冧滑銆傝闂帶鍒跺喅绛栧彇鍐充簬鍐呭瓨涓殑 鎺堟潈琛ㄧ殑浠芥暟銆
涓鑸儏鍐碉紝浣犻氳繃GRANT鍜REVOKE璇彞闂存帴鏉ユ搷浣 鎺堟潈琛ㄧ殑鍐呭锛岃缃处鎴峰苟鎺у埗涓汉鐨勬潈闄愩傚弬瑙13.5.1.3鑺傦紝鈥淕RANT鍜孯EVOKE璇硶鈥銆備笅闈㈣璁轰簡 鎺堟潈琛ㄧ殑缁撴瀯浠ュ強鏈嶅姟鍣ㄤ笌瀹㈡埛绔氦浜掓搷浣滄椂濡備綍浣跨敤鍏跺唴瀹广
鏈嶅姟鍣ㄥ湪瀛樺彇鎺у埗鐨勪袱涓樁娈典娇鐢mysql鏁版嵁搴撲腑鐨user銆db鍜host琛紝杩欎簺鎺堟潈琛ㄤ腑鐨勫垪濡備笅锛
琛ㄥ悕 |
user |
db |
host |
鍒楄寖鍥 |
Host |
Host |
Host |
|
User |
Db |
Db |
|
Password |
User |
|
鏉冮檺鍒 |
Select_priv |
Select_priv |
Select_priv |
|
Insert_priv |
Insert_priv |
Insert_priv |
|
Update_priv |
Update_priv |
Update_priv |
|
Delete_priv |
Delete_priv |
Delete_priv |
|
Index_priv |
Index_priv |
Index_priv |
|
Alter_priv |
Alter_priv |
Alter_priv |
|
Create_priv |
Create_priv |
Create_priv |
|
Drop_priv |
Drop_priv |
Drop_priv |
|
Grant_priv |
Grant_priv |
Grant_priv |
|
Create_view_priv |
Create_view_priv |
Create_view_priv |
|
Show_view_priv |
Show_view_priv |
Show_view_priv |
|
Create_routine_priv |
Create_routine_priv |
|
|
Alter_routine_priv |
Alter_routine_priv |
|
|
References_priv |
References_priv |
References_priv |
|
Reload_priv |
|
|
|
Shutdown_priv |
|
|
|
Process_priv |
|
|
|
File_priv |
|
|
|
Show_db_priv |
|
|
|
Super_priv |
|
|
|
Create_tmp_table_priv |
Create_tmp_table_priv |
Create_tmp_table_priv |
|
Lock_tables_priv |
Lock_tables_priv |
Lock_tables_priv |
|
Execute_priv |
|
|
|
Repl_slave_priv |
|
|
|
Repl_client_priv |
|
|
瀹夊叏鍒 |
ssl_type |
|
|
|
ssl_cipher |
|
|
|
x509_issuer |
|
|
|
x509_subject |
|
|
璧勬簮鎺у埗鍒 |
max_questions |
|
|
|
max_updates |
|
|
|
max_connections |
|
|
|
max_user_connections |
|
|
瀵瑰瓨鍙栨帶鍒剁殑绗簩闃舵(璇锋眰璇佸疄)锛屾湇鍔″櫒鎵ц璇锋眰楠岃瘉浠ョ‘淇濇瘡涓鎴风鏈夊厖鍒嗙殑鏉冮檺婊¤冻鍚勯渶姹傘傞櫎浜user銆db鍜host鎺堟潈琛紝濡傛灉璇锋眰娑夊強琛紝鏈嶅姟鍣ㄥ彲浠ュ彟澶栧弬鑰tables_priv鍜columns_priv琛ㄣtables_priv鍜columns_priv琛ㄥ彲浠ュ琛ㄥ拰鍒楁彁渚涙洿绮剧‘鐨勬潈闄愭帶鍒躲傝繖浜涜〃鐨勫垪濡備笅锛
琛ㄥ悕 |
tables_priv |
columns_priv |
鑼冨洿鍒 |
Host |
Host |
|
Db |
Db |
|
User |
User |
|
Table_name |
Table_name |
|
|
Column_name |
鏉冮檺鍒 |
Table_priv |
Column_priv |
|
Column_priv |
|
鍏跺畠鍒 |
Timestamp |
Timestamp |
|
Grantor |
|
Timestamp鍜Grantor鍒楀綋鍓嶈繕鏈娇鐢紝杩欏効涓嶅啀杩涗竴姝ヨ璁恒
涓轰簡瀵规秹鍙婁繚瀛樼▼搴忕殑璇锋眰杩涜楠岃瘉锛屾湇鍔″櫒灏嗘煡闃procs_priv琛ㄣ傝琛ㄥ叿鏈変互涓嬪垪锛
琛ㄥ悕 |
procs_priv |
鑼冨洿鍒 |
Host |
|
Db |
|
User |
|
Routine_name |
|
Routine_type |
鏉冮檺鍒 |
Proc_priv |
鍏跺畠鍒 |
Timestamp |
|
Grantor |
Routine_type鍒椾负ENUM鍒楋紝鍊间负'FUNCTION'鎴'PROCEDURE'锛岃〃绀鸿鎵鎸囩殑绋嬪簭绫诲瀷銆傝鍒楀厑璁镐负鍚屽悕鍑芥暟鍜岀▼搴忓崟鐙巿鏉冦
Timestamp鍜Grantor鍒楀綋鍓嶈繕鏈娇鐢紝杩欏効涓嶅啀杩涗竴姝ヨ璁恒
姣忎釜鎺堟潈琛ㄥ寘鍚寖鍥村垪鍜屾潈闄愬垪锛
l 鑼冨洿鍒楀喅瀹氳〃涓瘡涓潯鐩紙琛岋級鐨勮寖鍥达紝鍗筹紝琛岄傜敤鐨勪笂涓嬫枃銆備緥濡, 涓涓user琛ㄨ鐨Host鍜User鍊间负'thomas.loc.gov'鍜'bob'锛灏嗚鐢ㄤ簬璇佸疄鏉ヨ嚜涓绘満thomas.loc.gov鐨bob瀵规湇鍔″櫒鐨勮繛鎺ャ傚悓鏍凤紝涓涓db琛ㄨ鐨Host銆User鍜Db鍒楃殑鍊兼槸'thomas.loc.gov'銆'bob'鍜'reports'灏嗙敤鍦bob浠庝富鏈thomas.loc.gov鑱旀帴璁块棶reports鏁版嵁搴撶殑鏃跺欍tables_priv鍜columns_priv琛ㄥ寘鍚寖鍥村垪锛屾寚鍑烘瘡涓閫傜敤鐨勮〃鎴栬〃/鍒楃殑缁勫悎銆procs_priv鑼冨洿鍒楁寚鍑烘瘡涓閫傜敤鐨勪繚瀛樼▼搴忋
瀵逛簬妫鏌ュ瓨鍙栫殑鐢ㄩ旓紝姣旇緝Host鍊兼槸蹇界暐澶у皬鍐欑殑銆User銆Password銆Db鍜Table_name鍊兼槸鍖哄垎澶у皬鍐欑殑銆Column_name鍊煎湪MySQL3.22.12鎴栦互鍚庣増鏈槸蹇界暐澶у皬鍐欑殑銆
l 鏉冮檺鍒楁寚鍑虹敱涓涓〃琛屾巿浜堢殑鏉冮檺锛屽嵆锛屽彲瀹炴柦浠涔堟搷浣溿傛湇鍔″櫒缁勫悎鍚勭鐨勬巿鏉冭〃鐨勪俊鎭舰鎴愪竴涓敤鎴锋潈闄愮殑瀹屾暣鎻忚堪銆備负姝や娇鐢ㄧ殑瑙勫垯鍦5.7.6鑺傦紝鈥滆闂帶鍒, 闃舵2锛氳姹傛牳瀹炩鎻忚堪銆
鑼冨洿鍒楀寘鍚瓧绗︿覆锛屽涓嬫墍杩帮紱姣忎釜鍒楃殑榛樿鍊兼槸绌哄瓧绗︿覆锛
鍒楀悕 |
绫诲瀷 |
Host |
CHAR(60) |
User |
CHAR(16) |
Password |
CHAR(16) |
Db |
CHAR(64) |
Table_name |
CHAR(64) |
Column_name |
CHAR(64) |
Routine_name |
CHAR(64) |
涓轰簡璁块棶妫鏌ョ洰鐨勶紝Host鍊肩殑姣旇緝瀵瑰ぇ灏忓啓涓嶆晱鎰熴User銆Password銆Db鍜Table_name鍊煎澶у皬鍐欐晱鎰熴Column_name鍊煎澶у皬鍐欎笉鏁忔劅銆
鍦user銆db鍜host琛ㄤ腑锛屾墍鏈夋潈闄愬垪浜庡崟鐙殑鍒楀唴锛岃澹版槑涓ENUM('N','Y') DEFAULT 'N'銆鎹㈠彞璇濊锛姣忎竴涓潈闄愰兘鍙互琚鐢ㄥ拰鍚敤锛屽苟涓 榛樿鏄鐢銆
鍦tables_priv銆columns_priv鍜procs_priv琛ㄤ腑锛屾潈闄愬垪琚0鏄庝负SET鍒椼傝繖浜涘垪鐨勫煎彲浠ュ寘鍚琛ㄦ帶鍒剁殑鏉冮檺鐨勭粍鍚堬細
琛ㄥ悕 |
鍒楀悕 |
鍙兘鐨勮缃厓绱 |
tables_priv |
Table_priv |
'Select', 'Insert', 'Update', 'Delete', 'Create', 'Drop', 'Grant', 'References', 'Index', 'Alter' |
tables_priv |
Column_priv |
'Select', 'Insert', 'Update', 'References' |
columns_priv |
Column_priv |
'Select', 'Insert', 'Update', 'References' |
procs_priv |
Proc_priv |
'Execute', 'Alter Routine', 'Grant' |
绠鍗曞湴璇达紝鏈嶅姟鍣ㄤ娇鐢ㄨ繖鏍风殑鎺堟潈琛細
路 user琛ㄨ寖鍥村垪鍐冲畾鏄惁鍏佽鎴栨嫆缁濆埌鏉ョ殑杩炴帴銆傚浜庡厑璁哥殑杩炴帴锛user琛ㄦ巿浜堢殑鏉冮檺鎸囧嚭鐢ㄦ埛鐨勫叏灞(瓒呯骇鐢ㄦ埛)鏉冮檺銆傝繖浜涙潈闄愰傜敤浜庢湇鍔″櫒涓婄殑all鏁版嵁搴撱
路 db琛ㄨ寖鍥村垪鍐冲畾鐢ㄦ埛鑳戒粠鍝釜涓绘満瀛樺彇鍝釜鏁版嵁搴撱傛潈闄愬垪鍐冲畾鍏佽鍝釜鎿嶄綔銆傛巿浜堢殑鏁版嵁搴撶骇鍒殑鏉冮檺閫傜敤浜庢暟鎹簱鍜屽畠鐨勮〃銆
路 褰撲綘鎯宠涓涓粰瀹氱殑db琛ㄨ搴旂敤浜庤嫢骞蹭富鏈烘椂锛db鍜host琛ㄤ竴璧蜂娇鐢ㄣ備緥濡傦紝濡傛灉浣犳兂瑕佷竴涓敤鎴疯兘鍦ㄤ綘鐨勭綉缁滀粠鑻ュ共涓绘満浣跨敤涓涓暟鎹簱锛屽湪鐢ㄦ埛鐨db琛ㄨ鐨Host鍊艰涓虹┖鍊硷紝鐒跺悗灏嗛偅浜涗富鏈虹殑姣忎竴涓Щ鍏host琛ㄣ傝繖涓満鍒惰缁嗘弿杩板湪5.7.6鑺傦紝鈥滆闂帶鍒, 闃舵2锛氳姹傛牳瀹炩銆
娉閲婏細host琛ㄤ笉鍙GRANT鍜REVOKE璇彞鐨勫奖鍝嶃傚ぇ澶氭暟MySQL瀹夎鏍规湰涓嶉渶瑕佷娇鐢ㄨ琛ㄣ
路 tables_priv鍜columns_priv琛ㄧ被浼间簬db琛紝浣嗘槸鏇寸簿鑷达細瀹冧滑鍦ㄨ〃鍜屽垪绾у簲鐢ㄨ岄潪鍦ㄦ暟鎹簱绾с傛巿浜堣〃绾у埆鐨勬潈闄愰傜敤浜庤〃鍜屾墍鏈夊畠鐨勫垪銆傛巿浜堝垪绾у埆鐨勬潈闄愬彧閫傜敤浜庝笓鐢ㄥ垪銆
路 procs_priv琛ㄩ傜敤浜庝繚瀛樼殑绋嬪簭銆傛巿浜堢▼搴忕骇鍒殑鏉冮檺鍙傜敤浜庡崟涓▼搴忋
绠$悊鏉冮檺(渚嬪RELOAD鎴SHUTDOWN绛夌瓑)浠呭湪user琛ㄤ腑琚寚瀹氥傝繖鏄洜涓虹鐞嗘ф搷浣滄槸鏈嶅姟鍣ㄦ湰韬殑鎿嶄綔骞朵笖涓嶆槸鐗瑰畾鏁版嵁搴擄紝鍥犳娌℃湁鐞嗙敱鍦ㄥ叾浠栨巿鏉冭〃涓垪鍑鸿繖鏍风殑鏉冮檺銆備簨瀹炰笂锛屽彧闇瑕佹煡璇user琛ㄦ潵鍐冲畾浣犳槸鍚︽墽琛屼竴涓鐞嗘搷浣溿
FILE鏉冮檺涔熶粎鍦user琛ㄤ腑鎸囧畾銆傚畠涓嶆槸绠$悊鎬ф潈闄愶紝浣嗕綘鍦ㄦ湇鍔″櫒涓绘満涓婅鎴栧啓鏂囦欢鐨勮兘鍔涗笌浣犳鍦ㄥ瓨鍙栫殑鏁版嵁搴撴棤鍏炽
褰mysqld鏈嶅姟鍣ㄥ惎鍔ㄦ椂锛屽皢鎺堟潈琛ㄧ殑鍐呭璇诲叆鍒板唴瀛樹腑銆備綘鍙互閫氳繃FLUSH PRIVILEGES璇彞鎴栨墽琛mysqladmin flush-privileges鎴mysqladmin reload鍛戒护璁╁畠閲嶆柊璇诲彇琛ㄣ傚鎺堟潈琛ㄧ殑鏇存敼鐢熸晥鍦5.7.7鑺傦紝鈥滄潈闄愭洿鏀逛綍鏃剁敓鏁堚鎻忚堪銆
褰撲綘淇敼鎺堟潈琛ㄧ殑鍐呭鏃讹紝纭繚浣犳寜浣犳兂瑕佺殑鏂瑰紡鏇存敼鏉冮檺璁剧疆鏄竴涓ソ涓绘剰銆傝妫鏌ョ粰瀹氳处鎴风殑鏉冮檺锛屼娇鐢SHOW GRANTS璇彞銆備緥濡傦紝瑕佹鏌Host鍜User鍊煎垎鍒负pc84.example.com鍜bob鐨勮处鎴锋墍鎺堜簣鐨勬潈闄愶紝搴旈氳繃璇彞锛
mysql> SHOW GRANTS FOR 'bob'@'pc84.example.com';
涓涓湁鐢ㄧ殑璇婃柇宸ュ叿鏄mysqlaccess鑴氭湰锛岀敱Carlier Yves 鎻愪緵缁MySQL鍒嗗彂銆備娇鐢--help閫夐」璋冪敤mysqlaccess鏌ユ槑瀹冩庢牱宸ヤ綔銆傛敞鎰忥細mysqlaccess浠呯敤user銆db鍜host琛ㄦ鏌ュ瓨鍙栥傚畠涓嶆鏌tables_priv銆columns_priv鎴procs_priv琛ㄤ腑鎸囧畾鐨勮〃銆佸垪鍜岀▼搴忕骇鏉冮檺銆
瀵逛簬璇婃柇鏉冮檺鐩稿叧鐨勯棶棰樼殑鍏跺畠甯姪锛屽弬瑙5.7.8鑺傦紝鈥滄嫆缁濊闂敊璇殑鍘熷洜鈥銆傚浜庡畨鍏ㄩ棶棰樺父瑙勫缓璁紝鍙傝5.6鑺傦紝鈥滀竴鑸畨鍏ㄩ棶棰樷銆
璐︽埛鏉冮檺淇℃伅琚瓨鍌ㄥ湪mysql鏁版嵁搴撶殑user銆db銆host銆tables_priv銆columns_priv鍜procs_priv琛ㄤ腑銆傚湪MySQL鍚姩鏃跺苟鍦5.7.7鑺傦紝鈥滄潈闄愭洿鏀逛綍鏃剁敓鏁堚鎵璇寸殑鎯呭喌鏃讹紝鏈嶅姟鍣ㄥ皢杩欎簺鏁版嵁搴撹〃鍐呭璇诲叆鍐呭瓨銆
GRANT鍜REVOKE璇彞鎵鐢ㄧ殑娑夊強鏉冮檺鐨勫悕绉版樉绀哄湪涓嬭〃锛岃繕鏈夊湪鎺堟潈琛ㄤ腑姣忎釜鏉冮檺鐨勮〃鍒楀悕绉板拰姣忎釜鏉冮檺鏈夊叧鐨勪笂涓嬫枃銆傚叧浜庢瘡涓潈闄愮殑鍚箟鐩稿叧鐨勮缁嗕俊鎭弬瑙13.5.1.3鑺傦紝鈥淕RANT鍜孯EVOKE璇硶鈥銆
鏉冮檺 |
鍒 |
涓婁笅鏂 |
CREATE |
Create_priv |
鏁版嵁搴撱佽〃鎴栫储寮 |
DROP |
Drop_priv |
鏁版嵁搴撴垨琛 |
GRANT OPTION |
Grant_priv |
鏁版嵁搴撱佽〃鎴栦繚瀛樼殑绋嬪簭 |
REFERENCES |
References_priv |
鏁版嵁搴撴垨琛 |
ALTER |
Alter_priv |
琛 |
DELETE |
Delete_priv |
琛 |
INDEX |
Index_priv |
琛 |
INSERT |
Insert_priv |
琛 |
SELECT |
Select_priv |
琛 |
UPDATE |
Update_priv |
琛 |
CREATE VIEW |
Create_view_priv |
瑙嗗浘 |
SHOW VIEW |
Show_view_priv |
瑙嗗浘 |
ALTER ROUTINE |
Alter_routine_priv |
淇濆瓨鐨勭▼搴 |
CREATE ROUTINE |
Create_routine_priv |
淇濆瓨鐨勭▼搴 |
EXECUTE |
Execute_priv |
淇濆瓨鐨勭▼搴 |
FILE |
File_priv |
鏈嶅姟鍣ㄤ富鏈轰笂鐨勬枃浠惰闂 |
CREATE TEMPORARY TABLES |
Create_tmp_table_priv |
鏈嶅姟鍣ㄧ鐞 |
LOCK TABLES |
Lock_tables_priv |
鏈嶅姟鍣ㄧ鐞 |
CREATE USER |
Create_user_priv |
鏈嶅姟鍣ㄧ鐞 |
PROCESS |
Process_priv |
鏈嶅姟鍣ㄧ鐞 |
RELOAD |
Reload_priv |
鏈嶅姟鍣ㄧ鐞 |
REPLICATION CLIENT |
Repl_client_priv |
鏈嶅姟鍣ㄧ鐞 |
REPLICATION SLAVE |
Repl_slave_priv |
鏈嶅姟鍣ㄧ鐞 |
SHOW DATABASES |
Show_db_priv |
鏈嶅姟鍣ㄧ鐞 |
SHUTDOWN |
Shutdown_priv |
鏈嶅姟鍣ㄧ鐞 |
SUPER |
Super_priv |
鏈嶅姟鍣ㄧ鐞 |
褰撲粠鏃╂湡鐨勬病鏈CREATE VIEW銆SHOW VIEW銆CREATE ROUTINE銆ALTER ROUTINE鍜EXECUTE鏉冮檺鐨勭増鏈殑MySQL涓崌绾ф椂锛岃鎯充娇鐢ㄨ繖浜涙潈闄愶紝浣犲繀椤讳娇鐢MySQL鍒嗗彂鎻愪緵鐨mysql_fix_privilege_tables鑴氭湰鍗囩骇 鎺堟潈琛ㄣ傚弬瑙2.10.2鑺傦紝鈥滃崌绾ф巿鏉冭〃鈥銆
濡傛灉鍚敤浜嗕簩杩涘埗璁板綍锛岃鎯冲垱寤烘垨淇敼淇濆瓨鐨勭▼搴忥紝浣犺繕闇瑕SUPER鏉冮檺锛岃缁嗘弿杩拌20.4鑺傦紝鈥滃瓨鍌ㄥ瓙绋嬪簭鍜岃Е鍙戠▼搴忕殑浜岃繘鍒舵棩蹇楀姛鑳解銆
閫氳繃CREATE鍜DROP鏉冮檺锛屼綘鍙互鍒涘缓鏂版暟鎹簱鍜岃〃锛屾垨鍒犻櫎(绉绘帀)宸叉湁鏁版嵁搴撳拰琛ㄣ濡傛灉浣犲皢mysql鏁版嵁搴撲腑鐨DROP鏉冮檺鎺堜簣鏌愮敤鎴凤紝鐢ㄦ埛鍙互鍒犳帀MySQL璁块棶鏉冮檺淇濆瓨鐨勬暟鎹簱銆
SELECT銆INSERT銆UPDATE鍜DELETE鏉冮檺鍏佽浣犲湪涓涓暟鎹簱鐜版湁鐨勮〃涓婂疄鏂芥搷浣溿
SELECT璇彞鍙湁鍦ㄤ粬浠湡姝d粠涓涓〃涓绱㈣鏃舵墠闇瑕SELECT鏉冮檺銆備竴浜SELECT璇彞涓嶈闂〃锛岀敋鑷虫病鏈変换浣曞埌鏈嶅姟鍣ㄤ笂鐨勬暟鎹簱閲岀殑瀛樺彇浠讳綍涓滆タ鐨勮鍙備緥濡傦紝浣犲彲浣跨敤mysql瀹㈡埛绔綔涓轰竴涓畝鍗曠殑璁$畻鍣ㄦ潵璇勪及鏈紩鐢ㄨ〃鐨勮〃杈惧紡锛
mysql> SELECT 1+1;
mysql> SELECT PI()*2;
INDEX鏉冮檺鍏佽浣犲垱寤烘垨鍒犻櫎绱㈠紩銆INDEX閫傜敤宸叉湁琛銆濡傛灉浣犲叿鏈夋煇涓〃鐨CREATE鏉冮檺锛屼綘鍙互鍦CREATE TABLE璇彞涓寘鎷储寮曞畾涔夈
閫氳繃ALTER鏉冮檺锛屼綘鍙互浣跨敤ALTER TABLE鏉ユ洿鏀硅〃鐨勭粨鏋勫拰閲嶆柊鍛藉悕琛銆
闇瑕CREATE ROUTINE鏉冮檺鏉ュ垱寤轰繚瀛樼殑绋嬪簭锛堝嚱鏁板拰绋嬪簭锛夛紝ALTER ROUTINE鏉冮檺鏉ユ洿鏀瑰拰鍒犻櫎淇濆瓨鐨勭▼搴忥紝EXECUTE鏉ユ墽琛屼繚瀛樼殑绋嬪簭銆
GRANT鏉冮檺鍏佽浣犳妸浣犺嚜宸辨嫢鏈夌殑閭d簺鏉冮檺鎺堢粰鍏朵粬鐨勭敤鎴枫傚彲浠ョ敤浜庢暟鎹簱銆佽〃鍜屼繚瀛樼殑绋嬪簭銆
FILE鏉冮檺缁欎簣浣犵敤LOAD DATA INFILE鍜SELECT ... INTO OUTFILE璇彞璇诲拰鍐欐湇鍔″櫒涓婄殑鏂囦欢锛屼换浣曡鎺堜簣FILE鏉冮檺鐨勭敤鎴烽兘鑳借鎴栧啓MySQL鏈嶅姟鍣ㄨ兘璇绘垨鍐欑殑浠讳綍鏂囦欢銆(璇存槑鐢ㄦ埛鍙互璇讳换浣曟暟鎹簱鐩綍涓嬬殑鏂囦欢锛屽洜涓烘湇鍔″櫒鍙互璁块棶杩欎簺鏂囦欢锛銆 FILE鏉冮檺鍏佽鐢ㄦ埛鍦MySQL鏈嶅姟鍣ㄥ叿鏈夊啓鏉冮檺鐨勭洰褰曚笅鍒涘缓鏂版枃浠躲備笉鑳借鐩栧凡鏈夋枃浠躲
鍏朵綑鐨勬潈闄愮敤浜庣鐞嗘ф搷浣滐紝瀹冧娇鐢mysqladmin绋嬪簭鎴SQL璇彞瀹炴柦銆備笅琛ㄦ樉绀烘瘡涓鐞嗘ф潈闄愬厑璁镐綘鎵ц鐨mysqladmin鍛戒护锛
鏉冮檺 |
鏉冮檺鎷ユ湁鑰呭厑璁告墽琛岀殑鍛戒护 |
RELOAD |
flush-hosts, flush-logs, flush-privileges, flush-status, flush-tables, flush-threads, refresh, reload |
SHUTDOWN |
shutdown |
PROCESS |
processlist |
SUPER |
kill |
reload鍛戒护鍛婅瘔鏈嶅姟鍣ㄥ皢鎺堟潈琛ㄩ噸鏂拌鍏ュ唴瀛樸flush-privileges鏄reload鐨勫悓涔夎瘝锛refresh鍛戒护娓呯┖鎵鏈夎〃骞舵墦寮骞跺叧闂褰曟枃浠讹紝鍏跺畠flush-xxx鍛戒护鎵ц绫讳技refresh鐨勫姛鑳斤紝浣嗘槸鑼冨洿鏇存湁闄愶紝骞朵笖鍦ㄦ煇浜涙儏鍐典笅鍙兘鏇村ソ鐢ㄣ備緥濡傦紝濡傛灉浣犲彧鏄兂娓呯┖璁板綍鏂囦欢锛flush-logs姣refresh鏄洿濂界殑閫夋嫨銆
shutdown鍛戒护鍏虫帀鏈嶅姟鍣ㄣ傚彧鑳戒粠mysqladmin鍙戝嚭鍛戒护銆傛病鏈夌浉搴旂殑SQL璇彞銆
processlist鍛戒护鏄剧ず鍦ㄦ湇鍔″櫒鍐呮墽琛岀殑绾跨▼鐨勪俊鎭紙鍗冲叾瀹冭处鎴风浉鍏崇殑瀹㈡埛绔墽琛岀殑璇彞锛夈kill鍛戒护鏉姝绘湇鍔″櫒绾跨▼銆備綘鎬绘槸鑳芥樉绀烘垨鏉姝讳綘鑷繁鐨勭嚎绋嬶紝浣嗘槸浣犻渶瑕PROCESS鏉冮檺鏉ユ樉绀烘垨鏉姝诲叾浠栫敤鎴峰拰SUPER鏉冮檺鍚姩鐨勭嚎绋嬨鍙傝13.5.5.3鑺傦紝鈥淜ILL璇硶鈥銆
鎷ユ湁LOCK TABLES鏉冮檺渚垮彲浠ョ洿鎺ヤ娇鐢LOCK TABLES璇彞鏉ラ攣瀹氫綘鎷ユ湁SELECT鏉冮檺鐨勮〃銆傚寘鎷娇鐢ㄥ啓閿佸畾锛屽彲浠ラ槻姝粬浜鸿閿佸畾鐨勮〃銆
鎷ユ湁REPLICATION CLIENT鏉冮檺渚垮彲浠ヤ娇鐢SHOW MASTER STATUS鍜SHOW SLAVE STATUS銆
REPLICATION SLAVE鏉冮檺搴旀巿浜堜粠鏈嶅姟鍣ㄦ墍浣跨敤鐨勫皢褰撳墠鏈嶅姟鍣ㄨ繛鎺ヤ负涓绘湇鍔″櫒鐨勮处鎴銆傛病鏈夎繖涓潈闄愶紝浠庢湇鍔″櫒涓嶈兘鍙戝嚭瀵逛富鏈嶅姟鍣ㄤ笂鐨勬暟鎹簱鎵鍙戝嚭鐨勬洿鏂拌姹傘
鎷ユ湁SHOW DATABASES鏉冮檺渚垮厑璁歌处鎴蜂娇鐢SHOW DATABASE璇彞鏉ユ煡鐪嬫暟鎹簱鍚嶃傛病鏈夎鏉冮檺鐨勮处鎴峰彧鑳界湅鍒颁粬浠叿鏈夐儴鍒嗘潈闄愮殑鏁版嵁搴擄紝 濡傛灉鏁版嵁搴撶敤--skip-show-database閫夐」鍚姩锛屽垯鏍规湰涓嶈兘浣跨敤杩欎簺璇彞銆傝娉ㄦ剰鍏ㄥ眬鏉冮檺鎸囨暟鎹簱鐨勬潈闄愩
鎬荤殑璇存潵锛屽彧鎺堜簣鏉冮檺缁欓渶瑕佷粬浠殑閭d簺鐢ㄦ埛鏄ソ涓绘剰锛屼絾鏄綘搴旇鍦ㄦ巿浜FILE鍜岀鐞嗘潈闄愭椂璇曢獙鐗瑰畾鐨勮鍛婏細
鏈変竴浜涗簨鎯呬綘涓嶈兘鐢MySQL鏉冮檺绯荤粺鍋氬埌锛
褰撲綘鎯宠璁块棶MySQL鏈嶅姟鍣ㄦ椂锛MySQL瀹㈡埛绔▼搴忎竴鑸姹備綘鎸囧畾鍙傛暟锛
路 MySQL鏈嶅姟鍣ㄨ繍琛岀殑涓绘満鍚
路 濮撳悕
路 瀵嗙爜
渚嬪锛屽彲浠ヤ粠鍛戒护琛屾寜鐓т笅杩版彁绀哄惎鍔MySQL瀹㈡埛绔(鐢shell>琛ㄧず)锛
shell> MySQL -h host_name -u user_name -pyour_pass
-h, -u鍜-p閫夐」杩樺彲浠ラ噰鐢ㄥ舰寮--host=host_name銆--user=user_name鍜--password=your_pass銆傝娉ㄦ剰鍦-p鎴--password=鍜屽悗闈㈢殑瀵嗙爜涔嬮棿娌℃湁绌烘牸銆
濡傛灉浣犱娇鐢-p鎴--password閫夐」浣嗘病鏈夋寚瀹氬瘑鐮佸硷紝瀹㈡埛绔▼搴忔彁绀轰綘杈撳叆瀵嗙爜銆傚綋浣犺緭鍏ュ瘑鐮佹椂骞朵笉鏄剧ず瀵嗙爜銆傝繖姣斿湪鍦ㄥ懡浠よ杈撳叆瀵嗙爜瑕佸畨鍏ㄥ緱澶氥傜郴缁熶笂鐨勪换浣曠敤鎴峰彲浠ラ氳繃鍛戒护ps auxww鍦ㄥ懡浠よ涓寚瀹氬瘑鐮併傚弬瑙5.8.6鑺傦紝鈥滀娇浣犵殑瀵嗙爜瀹夊叏鈥銆
濡傛灉娌℃湁鎸囧畾杩炴帴鍙傛暟锛MySQL瀹㈡埛绔▼搴忎娇鐢ㄩ粯璁ゅ硷細
路 濡傛灉娌℃湁-p锛屽垯涓嶆彁渚涘瘑鐮併
杩欐牱, 瀵Unix鐢ㄦ埛joe锛屼笅鍒楀懡浠ゆ槸绛変环鐨勶細
shell> MySQL -h localhost -u joe
shell> MySQL -h localhost
shell> MySQL -u joe
shell> MySQL
鍏跺畠MySQL瀹㈡埛绔▼搴忕被浼笺
褰撹繘琛岃繛鎺ユ椂锛屼綘鍙互鎸囧畾瑕佷娇鐢ㄧ殑涓嶅悓鐨勯粯璁ゅ硷紝杩欐牱涓嶅繀姣忔鍦ㄤ綘璋冪敤瀹㈡埛绔▼搴忔槸鍦ㄥ懡浠よ涓婅緭鍏ュ畠浠傝繖鍙互鏈夊緢澶氭柟娉曞仛鍒帮細
路 [client]
路 host=host_name
路 user=user_name
路 password=your_pass
鍦4.3.2鑺傦紝鈥滀娇鐢ㄩ夐」鏂囦欢鈥涓缁嗚璁轰簡閫夐」鏂囦欢銆
褰撲綘璇曞浘杩炴帴MySQL鏈嶅姟鍣ㄦ椂锛屾湇鍔″櫒鍩轰簬浣犵殑韬唤浠ュ強浣犳槸鍚﹁兘閫氳繃渚涘簲姝g‘鐨勫瘑鐮侀獙璇佽韩浠芥潵鎺ュ彈鎴栨嫆缁濊繛鎺ャ傚鏋滀笉鏄紝鏈嶅姟鍣ㄥ畬鍏ㄦ嫆缁濅綘鐨勮闂紝鍚﹀垯锛屾湇鍔″櫒鎺ュ彈杩炴帴锛岀劧鍚庤繘鍏ラ樁娈2骞朵笖绛夊緟璇锋眰銆
浣犵殑韬唤鍩轰簬2涓俊鎭細
韬唤妫鏌ヤ娇鐢3涓user琛(Host, User鍜Password)鑼冨洿鍒楁墽琛屻傛湇鍔″櫒鍙湁鍦user琛ㄨ褰曠殑Host鍜User鍒楀尮閰嶅鎴风涓绘満鍚嶅拰鐢ㄦ埛鍚嶅苟涓旀彁渚涗簡姝g‘鐨勫瘑鐮佹椂鎵嶆帴鍙楄繛鎺ャ
鍦user琛Host鍊肩殑鎸囧畾鏂规硶锛
路 瀵逛簬鎸囧畾涓IP鍙风殑Host鍊硷紝浣犲彲浠ユ寚瀹氫竴涓綉缁滄帺鐮侊紝璇存槑浣跨敤澶氬皯浣嶅湴鍧浣嶆潵璇勬瘮缃戠粶鍙枫備緥濡傦細
路 mysql> GRANT ALL PRIVILEGES ON db.*
路 -> -> TO david@'192.58.197.0/255.255.255.0';
鍏佽david浠庝换浣曞鎴风鐢IP鍙client_ip鏉ヨ繛鎺ワ紝涓嬮潰鐨勬潯浠朵负鐪燂細
client_ip & netmask = host_ip
That is, for the GRANT statement just shown:
client_ip & 255.255.255.0 = 192.58.197.0
婊¤冻璇ユ潯浠跺苟鍙互杩炴帴MySQL鏈嶅姟鍣ㄧ殑IP鍙风殑鑼冨洿涓192.58.197.0鍒192.58.197.255銆
路 娉ㄩ噴锛氱綉缁滄帺鐮佸彧鐢ㄦ潵鍛婅瘔鏈嶅姟鍣ㄤ娇鐢8銆16銆24鎴32浣嶅湴鍧锛屼緥濡傦細
路 192.0.0.0/255.0.0.0(192 A绫荤綉缁滅殑浠讳綍鍦板潃)
路 192.168.0.0/255.255.0.0(192.168 A绫荤綉缁滅殑浠讳綍鍦板潃)
路 192.168.1.0/255.255.255.0(192.168.1 C绫荤綉缁滅殑浠讳綍鍦板潃)
路 192.168.1.1(鍙湁璇IP)
涓嬮潰鐨勭綉缁滄帺鐮(28 浣)鏃犳晥锛
192.168.0.1/255.255.255.240
路 db琛ㄨ褰曚腑鐨勭┖Host鍊艰〃绀哄畠鐨勬潈闄愬簲缁撳悎鍖归厤瀹㈡埛绔悕鐨host琛ㄤ腑鐨勮浣跨敤銆傞氳繃AND(鐩镐笌)鑰屼笉鏄垨(鑱斿悎)鎿嶄綔灏嗘潈闄愮粍鍚堝埌涓璧枫備綘鍙互浠5.7.6鑺傦紝鈥滆闂帶鍒, 闃舵2锛氳姹傛牳瀹炩鎵惧埌鍏充簬host琛ㄧ殑璇︾粏淇℃伅銆
鍏跺畠grant琛ㄧ殑绌Host鍊间笌'%'鐩稿悓銆
鏃㈢劧浣犺兘鍦Host瀛楁浣跨敤IP閫氶厤绗﹀(渚嬪锛'144.155.166.%'鍖归厤鍦ㄤ竴涓瓙缃戜笂鐨勬瘡鍙颁富鏈)锛屾湁鍙兘鏌愪汉鍙兘浼佸浘鎺㈢┒杩欑鑳藉姏锛岄氳繃鍛藉悕涓鍙颁富鏈轰负144.155.166.somewhere.com銆備负浜嗛樆姝㈣繖鏍风殑浼佸浘锛MySQL涓嶅厑璁稿尮閰嶄互鏁板瓧鍜屼竴涓偣璧峰鐨勪富鏈哄悕锛岃繖鏍凤紝濡傛灉浣犵敤涓涓懡鍚嶄负绫讳技1.2.foo.com鐨勪富鏈猴紝瀹冪殑鍚嶅瓧鍐充笉浼氬尮閰嶆巿鏉冭〃涓殑Host鍒椼傚彧鏈変竴涓IP鏁板瓧鑳藉尮閰IP閫氶厤绗﹀笺
閫氶厤绗﹀瓧绗﹀湪User鍒椾腑涓嶅厑璁革紝浣嗘槸浣犺兘鎸囧畾绌虹殑鍊硷紝瀹冨尮閰嶄换浣曞悕瀛椼傚鏋user琛ㄥ尮閰嶇殑杩炴帴鏈変竴涓┖鐢ㄦ埛鍚嶏紝鐢ㄦ埛琚涓烘槸鍖垮悕鐢ㄦ埛(娌℃湁鍚嶅瓧鐨勭敤鎴)锛岃岄潪瀹㈡埛绔疄闄呮寚瀹氱殑鍚嶅瓧銆傝繖鎰忓懗鐫涓涓┖鐨勭敤鎴峰悕琚敤浜庡湪杩炴帴鏈熼棿鐨勮繘涓姝ョ殑璁块棶妫鏌(鍗筹紝鍦ㄩ樁娈2鏈熼棿)銆
Password鍒楀彲浠ユ槸绌虹殑銆傝繖涓嶆槸閫氶厤绗︼紝涔熶笉鎰忓懗鐫鍖归厤浠讳綍瀵嗙爜锛屽畠鎰忓懗鐫鐢ㄦ埛蹇呴』涓嶆寚瀹氫竴涓瘑鐮佽繘琛岃繛鎺ャ
user琛ㄤ腑鐨闈炵┖Password鍊间唬琛ㄥ姞瀵嗙殑瀵嗙爜銆MySQL涓嶄互浠讳綍浜哄彲浠ョ湅鐨勬槑鏂囨枃鏈牸寮忓瓨鍌ㄥ瘑鐮侊紝鐩稿弽锛屾鍦ㄨ瘯鍥捐仈鎺ョ殑鐢ㄦ埛鎻愪緵鐨勫瘑鐮佽鍔犲瘑(浣跨敤PASSWORD( )鍑芥暟)锛屽湪杩炴帴杩囩▼涓娇鐢ㄥ姞瀵嗙殑瀵嗙爜妫鏌ュ瘑鐮佹槸鍚︽纭(鍔犲瘑鍚庣殑瀵嗙爜鏈氳繃杩炴帴鍗冲彲瀹炵幇锛銆浠MySQL瑙掑害锛屽姞瀵嗙殑瀵嗙爜鏄疄闄呭瘑鐮侊紝鍥犳浣犱笉搴旇鍏跺畠浜鸿闂畠锛佺壒鍒槸锛岀粷瀵逛笉瑕佽闈炵鐞嗙敤鎴疯mysql鏁版嵁搴撲腑鐨勮〃锛
MySQL 5.1浣跨敤寮洪壌瀹氭柟娉(鏈鍏堝湪MySQL 4.1涓傜敤)鍦ㄥ墠闈㈢殑鐗堟湰涓湪杩炴帴杩涚▼涓殑瀵嗙爜淇濇姢杈冨ソ銆傚嵆浣TCP/IP鍖呰鎴彇鎴mysql鏁版嵁搴 琚崟鑾蜂篃寰堝畨鍏ㄣ5.7.9鑺傦紝鈥淢ySQL 4.1涓殑瀵嗙爜鍝堝笇澶勭悊鈥涓缁嗚璁轰簡瀵嗙爜鍔犲瘑銆
涓嬮潰鐨勪緥瀛愭樉绀哄嚭鍚勭user琛ㄤ腑Host鍜User鍊肩殑缁勫悎濡備綍搴旂敤浜庡埌鏉ョ殑杩炴帴锛
Host鍊 |
User鍊 |
琚潯鐩尮閰嶇殑杩炴帴 |
'thomas.loc.gov' |
'fred' |
fred, 浠thomas.loc.gov 杩炴帴 |
'thomas.loc.gov' |
'' |
浠讳綍鐢ㄦ埛, 浠thomas.loc.gov杩炴帴 |
'%' |
'fred' |
fred, 浠庝换浣曚富鏈鸿繛鎺 |
'%' |
'' |
浠讳綍鐢ㄦ埛, 浠庝换浣曚富鏈鸿繛鎺 |
'%.loc.gov' |
'fred' |
fred, 浠庡湪loc.gov鍩熺殑浠讳綍涓绘満杩炴帴 |
'x.y.%' |
'fred' |
fred, 浠x.y.net銆x.y.com,x.y.edu绛夎仈鎺ャ傦紙杩欐垨璁告棤鐢級 |
'144.155.166.177' |
'fred' |
fred, 浠庢湁144.155.166.177 IP鍦板潃鐨勪富鏈鸿繛鎺 |
'144.155.166.%' |
'fred' |
fred, 浠144.155.166 C绫诲瓙缃戠殑浠讳綍涓绘満杩炴帴 |
鍒版潵鐨勮繛鎺ヤ腑鐨勫鎴风鍚嶅拰鐢ㄦ埛鍚嶅彲鑳戒笌user琛ㄤ腑鐨勫琛屽尮閰嶃備緥濡傦紝鐢fred浠thomas.loc.gov鐨勮繛鎺ュ尮閰嶅涓潯鐩涓婃墍杩般
濡傛灉鏈夊涓尮閰嶏紝鏈嶅姟鍣ㄥ繀椤婚夋嫨浣跨敤鍝釜鏉$洰銆傛寜鐓т笅杩版柟娉曡В鍐抽棶棰橈細
l 鏈嶅姟鍣ㄥ湪鍚姩鏃惰鍏user琛ㄥ悗杩涜鎺掑簭銆
l 鐒跺悗褰撶敤鎴疯瘯鍥捐繛鎺ユ椂锛屼互鎺掑簭鐨勯『搴忔祻瑙堟潯鐩
l 鏈嶅姟鍣ㄤ娇鐢ㄤ笌瀹㈡埛绔拰鐢ㄦ埛鍚嶅尮閰嶇殑绗竴琛屻
user琛ㄦ帓搴忓伐浣滃涓嬶紝鍋囧畾user琛ㄧ湅璧锋潵鍍忚繖鏍凤細
+-----------+----------+-
| Host | User | 鈥
+-----------+----------+-
| % | root | 鈥
| % | jeffrey | 鈥
| localhost | root | 鈥
| localhost | | 鈥
+-----------+----------+-
褰撴湇鍔″櫒璇诲彇琛ㄦ椂锛屽畠棣栧厛浠ユ渶鍏蜂綋鐨Host鍊兼帓搴忋備富鏈哄悕鍜IP鍙锋槸鏈鍏蜂綋鐨勩'%'鎰忓懗鐫鈥滀换浣曚富鏈衡濆苟涓旀槸鏈涓嶇壒瀹氱殑銆傛湁鐩稿悓Host鍊肩殑鏉$洰棣栧厛浠ユ渶鍏蜂綋鐨User鍊兼帓搴(绌User鍊兼剰鍛崇潃鈥滀换浣曠敤鎴封濆苟涓旀槸鏈涓嶇壒瀹氱殑)銆傛渶缁堟帓搴忕殑user琛ㄧ湅璧锋潵鍍忚繖鏍凤細
+-----------+----------+-
| Host | User | 鈥
+-----------+----------+-
| localhost | root | 鈥 ...
| localhost | | 鈥 ...
| % | jeffrey | 鈥 ...
| % | root | 鈥 ...
+-----------+----------+-
褰撳鎴风璇曞浘杩炴帴鏃讹紝鏈嶅姟鍣ㄦ祻瑙堟帓搴忕殑鏉$洰骞朵娇鐢ㄦ壘鍒扮殑绗竴鍖归厤銆傚浜庣敱jeffrey浠localhost鐨勮繛鎺ワ紝琛ㄥ唴鏈変袱涓潯鐩尮閰嶏細Host鍜User鍊间负'localhost'鍜''鐨勬潯鐩紝鍜屽间负'%'鍜'jeffrey'鐨勬潯鐩'localhost'鏉$洰棣栧厛鍖归厤锛屾湇鍔″櫒鍙互浣跨敤銆
杩樻湁涓涓緥瀛愩傚亣瀹user琛ㄧ湅璧锋潵鍍忚繖鏍凤細
+----------------+----------+-
| Host | User | 鈥
+----------------+----------+-
| % | jeffrey | 鈥
| thomas.loc.gov | | 鈥
+----------------+----------+-
鎺掑簭鍚庣殑琛ㄧ湅璧锋潵鍍忚繖鏍凤細
+----------------+----------+-
| Host | User | 鈥
+----------------+----------+-
| thomas.loc.gov | | 鈥
| % | jeffrey | 鈥
+----------------+----------+-
鐢jeffrey浠thomas.loc.gov鐨勮繛鎺ヤ笌绗竴琛屽尮閰嶏紝鑰岀敱jeffrey浠whitehouse.gov鐨勮繛鎺ヨ绗簩涓尮閰嶃
鏅亶鐨勮瑙f槸璁や负锛屽缁欏畾鐨勭敤鎴峰悕锛屽綋鏈嶅姟鍣ㄨ瘯鍥惧杩炴帴瀵绘壘鍖归厤鏃讹紝鏄庣‘鍛藉悕閭d釜鐢ㄦ埛鐨勬墍鏈夋潯鐩皢棣栧厛琚娇鐢ㄣ傝繖鏄庢樉涓嶇鍚堜簨瀹炪傚厛鍓嶇殑渚嬪瓙璇存槑浜嗚繖鐐癸紝鍦ㄩ偅閲岀敱jeffrey浠thomas.loc.gov鐨勮繛鎺ユ病琚寘鍚'jeffrey'浣滀负User鍒楀肩殑琛屽尮閰嶏紝浣嗘槸鐢辨病鏈夌敤鎴峰悕鐨勯鐩尮閰嶏紒缁撴灉鏄紝jeffrey琚壌瀹氫负鍖垮悕鐢ㄦ埛锛屽嵆浣夸粬杩炴帴鏃舵寚瀹氫簡鐢ㄦ埛鍚嶃
濡傛灉浣犺兘澶熻繛鎺ユ湇鍔″櫒锛屼絾浣犵殑鏉冮檺涓嶆槸浣犳湡鏈涚殑锛屼綘鍙兘琚壌瀹氫负鍏跺畠璐︽埛銆傝鎯虫壘鍑烘湇鍔″櫒鐢ㄦ潵閴村畾浣犵殑璐︽埛锛屼娇鐢CURRENT_USER()鍑芥暟銆傚畠杩斿洖user_name@host_name鏍煎紡鐨勫硷紝璇存槑User鍜Host 鍊煎尮閰user琛ㄨ褰曘傚亣瀹jeffrey杩炴帴骞跺彂鍑轰笅闈㈢殑鏌ヨ锛
mysql> SELECT CURRENT_USER();
+----------------+
| CURRENT_USER() |
+----------------+
| @localhost |
+----------------+
杩欏効鏄剧ず鐨勭粨鏋滆鏄user琛ㄨ鏈夌┖鐨User鍒楀笺傛崲鍙ヨ瘽璇达紝鏈嶅姟鍣ㄥ皢jeffrey瑙嗕负鍖垮悕鐢ㄦ埛銆
璇婃柇閴村畾闂鐨勫彟涓涓柟娉曟槸鎵撳嵃鍑user琛ㄥ苟涓旀墜鍔ㄦ帓搴忓畠鐪嬬湅绗竴涓尮閰嶅湪鍝効杩涜銆傚張瑙12.9.3鑺傦紝鈥滀俊鎭嚱鏁扳銆
涓鏃︿綘寤虹珛浜嗚繛鎺ワ紝鏈嶅姟鍣ㄨ繘鍏ヨ闂帶鍒剁殑闃舵2銆傚鍦ㄦ杩炴帴涓婅繘鏉ョ殑姣忎釜璇锋眰锛屾湇鍔″櫒妫鏌ヤ綘鎯虫墽琛屼粈涔堟搷浣滐紝鐒跺悗妫鏌ユ槸鍚︽湁瓒冲鐨勬潈闄愭潵鎵ц瀹冦傝繖姝f槸鍦ㄦ巿鏉冭〃涓殑鏉冮檺鍒楀彂鎸ヤ綔鐢ㄧ殑鍦版柟銆傝繖浜涙潈闄愬彲浠ユ潵鑷user銆db銆host銆tables_priv鎴columns_priv琛ㄣ傦紙浣犱細鍙戠幇鍙傝5.7.2鑺傦紝鈥滄潈闄愮郴缁熷伐浣滃師鐞嗏寰堟湁甯姪锛屽畠鍒楀嚭浜嗘瘡涓 鎺堟潈琛ㄤ腑鍛堢幇鐨勫垪銆傦級
user琛ㄥ湪鍏ㄥ眬鍩虹涓婃巿浜堣祴浜堜綘鐨勬潈闄愶紝璇ユ潈闄愪笉绠″綋鍓嶇殑鏁版嵁搴撴槸浠涔堝潎閫傜敤銆備緥濡傦紝濡傛灉user琛ㄦ巿浜堜綘DELETE鏉冮檺锛 浣犲彲浠ュ垹闄ゅ湪鏈嶅姟鍣ㄤ富鏈轰笂浠庝换浣曟暟鎹簱鍒犻櫎琛岋紒鎹㈠彞璇濊锛user琛ㄦ潈闄愭槸瓒呯骇鐢ㄦ埛鏉冮檺銆傚彧鎶user琛ㄧ殑鏉冮檺鎺堜簣瓒呯骇鐢ㄦ埛濡傛湇鍔″櫒鎴栨暟鎹簱涓荤鏄槑鏅虹殑銆傚鍏朵粬鐢ㄦ埛锛屼綘搴旇鎶婂湪user琛ㄤ腑鐨勬潈闄愯鎴'N'骞朵笖浠呭湪鐗瑰畾鏁版嵁搴撶殑鍩虹涓婃巿鏉冦備綘鍙互涓虹壒瀹氱殑鏁版嵁搴撱佽〃鎴栧垪鎺堟潈銆
db鍜host琛ㄦ巿浜堟暟鎹簱鐗瑰畾鐨勬潈闄愩傚湪杩欎簺琛ㄤ腑鐨勮寖鍥村垪鐨勫煎彲浠ラ噰鐢ㄤ互涓嬫柟寮忥細
db鍜host琛ㄥ湪鏈嶅姟鍣ㄥ惎鍔ㄦ椂琚鍙栧苟鎺掑簭(鍚屾椂瀹冭user琛)銆db琛ㄥ湪Host銆Db鍜User鑼冨洿鍒椾笂鎺掑簭锛屽苟涓host琛ㄥ湪Host鍜Db鑼冨洿鍒椾笂鎺掑簭銆傚浜user琛紝棣栧厛鏍规嵁鏈鍏蜂綋鐨勫兼渶鍚庢牴鎹渶涓嶅叿浣撶殑鍊兼帓搴忥紝骞朵笖褰撴湇鍔″櫒瀵绘壘鍖归厤鏉$洰鏃讹紝瀹冧娇鐢ㄥ畠鎵惧埌鐨勭涓鍖归厤銆
tables_priv鍜columns_priv琛ㄦ巿浜堣〃鍜屽垪鐗瑰畾鐨勬潈闄愩傝繖浜涜〃鐨勮寖鍥村垪鐨勫煎彲浠ュ涓嬭鎸囧畾锛
tables_priv鍜columns_priv琛ㄦ牴鎹Host銆Db鍜User鍒楄鎺掑簭銆傝繖绫讳技浜db琛ㄧ殑鎺掑簭锛屽洜涓哄彧鏈Host鍒楀彲浠ュ寘鍚氶厤绗︼紝鎺掑簭鏇寸畝鍗曘
璇锋眰璇佸疄杩涚▼鍦ㄤ笅闈㈡弿杩般傦紙濡傛灉浣犵啛鎮夎闂鏌ョ殑婧愮爜锛屼綘浼氭敞鎰忓埌杩欓噷鐨勬弿杩颁笌鍦ㄤ唬鐮佷娇鐢ㄧ殑绠楁硶鐣ユ湁涓嶅悓銆傛弿杩扮瓑浠蜂簬浠g爜瀹為檯鍋氱殑涓滆タ锛涗笉鍚屽鍙槸浣胯В閲婃洿绠鍗曘傦級
瀵归渶瑕佺鐞嗘潈闄愮殑璇锋眰(SHUTDOWN銆RELOAD绛夌瓑)锛屾湇鍔″櫒浠呮鏌user琛ㄦ潯鐩紝鍥犱负閭f槸鍞竴鎸囧畾绠$悊鏉冮檺鐨勮〃銆傚鏋滆璁稿彲璇锋眰鐨勬搷浣滐紝璁块棶琚巿鏉冿紝鍚﹀垯鎷掔粷銆備緥濡傦紝濡傛灉浣犳兂瑕佹墽琛mysqladmin shutdown锛屼絾鏄敱浜user琛ㄨ娌℃湁涓轰綘鎺堜簣HUTDOWN鏉冮檺锛岀敋鑷充笉鐢ㄦ鏌db鎴host琛ㄥ氨鎷掔粷浣犵殑璁块棶銆傦紙鍥犱负瀹冧滑涓嶅寘鍚hutdown_priv琛屽垪锛屾病鏈夎繖鏍峰仛鐨勫繀瑕併傦級
瀵规暟鎹簱鏈夊叧鐨勮姹(INSERT銆UPDATE绛夌瓑)锛屾湇鍔″櫒棣栧厛閫氳繃鏌ユ壘user琛ㄨ鏉ユ鏌ョ敤鎴风殑鍏ㄥ眬(瓒呯骇鐢ㄦ埛)鏉冮檺銆傚鏋滆鍏佽璇锋眰鐨勬搷浣滐紝璁块棶琚巿鏉冦傚鏋滃湪user琛ㄤ腑鍏ㄥ眬鏉冮檺涓嶅锛屾湇鍔″櫒閫氳繃妫鏌db鍜host琛ㄧ‘瀹氱壒瀹氱殑鐢ㄦ埛鏁版嵁搴撴潈闄愶細
鍦ㄧ‘瀹氫簡鐢db鍜host琛ㄨ鎺堜簣鐨勬暟鎹簱鐗瑰畾鐨勬潈闄愬悗锛屾湇鍔″櫒鎶婁粬浠姞鍒扮敱user琛ㄦ巿浜堢殑鍏ㄥ眬鏉冮檺涓傚鏋滅粨鏋滃厑璁歌姹傜殑鎿嶄綔锛岃闂鎺堟潈銆傚惁鍒欙紝鏈嶅姟鍣ㄦ鏌ュ湪tables_priv鍜columns_priv琛ㄤ腑鐨勭敤鎴风殑琛ㄥ拰鍒楁潈闄愬苟鎶婂畠浠姞鍒扮敤鎴锋潈闄愪腑銆傚熀浜庢缁撴灉鍏佽鎴栨嫆缁濊闂
鐢ㄥ竷灏旀湳璇〃绀猴紝鍓嶉潰鍏充簬鐢ㄦ埛鏉冮檺濡備綍璁$畻鐨勬弿杩板彲浠ヨ繖鏍锋荤粨锛
global privileges
OR (database privileges AND host privileges)
OR table privileges
OR column privileges
瀹冨彲鑳戒笉鏄庢樉锛屼负浠涔堝憿锛屽鏋滃叏灞user琛岀殑鏉冮檺鏈鍒濆彂鐜板璇锋眰鐨勬搷浣滀笉澶燂紝鏈嶅姟鍣ㄤ互鍚庢妸杩欎簺鏉冮檺鍔犲埌鏁版嵁搴撱佽〃骞跺垪鐨勭壒瀹氭潈闄愩傚師鍥犳槸璇锋眰鍙兘瑕佹眰瓒呰繃涓绉嶇被鍨嬬殑鏉冮檺銆備緥濡傦紝濡傛灉浣犳墽琛INSERT INTO ... SELECT璇彞锛屼綘灏遍渶瑕INSERT鍜SELECT鏉冮檺銆備綘鐨勬潈闄愬繀椤绘槸user琛ㄨ鎺堜簣涓涓潈闄愯db琛ㄨ鎺堜簣鍙︿竴涓潈闄愩傚湪杩欑鎯呭喌涓嬶紝浣犳湁蹇呰鐨勬潈闄愭墽琛岃姹傦紝浣嗘槸鏈嶅姟鍣ㄤ笉鑳借嚜宸辨妸涓や釜琛ㄥ尯鍒紑鏉ワ紱涓や釜琛屾巿浜堢殑鏉冮檺蹇呴』缁勫悎璧锋潵銆
host琛ㄤ笉鍙GRANT鎴REVOKE璇彞鐨勫奖鍝嶏紝鍥犳鍦ㄥぇ澶氭暟MySQL瀹夎涓病鏈変娇鐢ㄣ傚鏋滀綘鐩存帴淇敼瀹冿紝浣犲彲浠ョ敤浜庢煇绉嶄笓闂ㄧ洰鐨勶紝渚嬪鐢ㄦ潵缁存姢瀹夊叏鏈嶅姟鍣ㄥ垪琛ㄣ備緥濡傦紝鍦TcX锛host琛ㄥ寘鍚湪鏈湴缃戠粶涓婃墍鏈夌殑鏈哄櫒鐨勮〃銆傝繖浜涜〃琚巿浜堟墍鏈夌殑鏉冮檺銆
浣犱篃鍙互浣跨敤host琛ㄦ寚瀹涓瀹夊叏鐨勪富鏈恒傚亣瀹氫綘鏈変竴鍙版満鍣public.your.domain锛屽畠浣嶄簬浣犺涓轰笉瀹夊叏鐨勫叕鍏卞尯鍩燂紝浣犲彲浠ョ敤涓嬪垪鐨host琛ㄦ潯鐩厑璁搁櫎浜嗛偅鍙版満鍣ㄥ鐨勭綉缁滀笂鎵鏈変富鏈虹殑璁块棶锛
+--------------------+----+-
| Host | Db | ...
+--------------------+----+-
| public.your.domain | % | ... (all privileges set to 'N')
| %.your.domain | % | ... (all privileges set to 'Y')
+--------------------+----+-
褰撶劧锛屼竴瀹氳娴嬭瘯鎺堟潈琛ㄤ腑鐨勮(渚嬪锛屼娇鐢SHOW GRANTS鎴mysqlaccess)锛岀‘淇濅綘鐨勮闂潈闄愬疄闄呮寜浣犳湡鏈涚殑鏂瑰紡琚缃
褰mysqld鍚姩鏃讹紝鎵鏈夋巿鏉冭〃鐨勫唴瀹硅璇昏繘鍐呭瓨骞朵笖浠庢鏃剁敓鏁堛
褰撴湇鍔″櫒娉ㄦ剰鍒版巿鏉冭〃琚敼鍙樹簡鏃讹紝鐜板瓨鐨勫鎴风杩炴帴鏈夊涓嬪奖鍝嶏細
路 鍏ㄥ眬鏉冮檺鐨勬敼鍙樺拰瀵嗙爜鏀瑰彉鍦ㄤ笅涓娆″鎴风杩炴帴鏃剁敓鏁堛
濡傛灉鐢GRANT銆REVOKE鎴SET PASSWORD瀵规巿鏉冭〃杩涜淇敼锛屾湇鍔″櫒浼氭敞鎰忓埌骞剁珛鍗抽噸鏂板皢鎺堟潈琛ㄨ浇鍏ュ唴瀛樸
濡傛灉浣犳墜鍔ㄥ湴淇敼鎺堟潈琛(浣跨敤INSERT銆UPDATE鎴DELETE绛夌瓑)锛屼綘搴旇鎵цmysqladmin flush-privileges鎴mysqladmin reload鍛婅瘔鏈嶅姟鍣ㄥ啀瑁呰浇鎺堟潈琛紝鍚﹀垯浣犵殑鏇存敼灏涓嶄細鐢熸晥锛岄櫎闈炰綘閲嶅惎鏈嶅姟鍣ㄣ
濡傛灉浣犵洿鎺ユ洿鏀逛簡鎺堟潈琛ㄤ絾蹇樿閲嶈浇锛岄噸鍚湇鍔″櫒鍚庝綘鐨勬洿鏀规柟鐢熸晥銆傝繖鏍峰彲鑳借浣犺糠鎯戜负浠涔堜綘鐨勬洿鏀规病鏈変粈涔堝彉鍖栵紒
褰撲綘璇曠潃鑱旀帴MySQL鏈嶅姟鍣ㄦ椂锛屽鏋滅鍒伴棶棰橈紝涓嬮潰鍚勯」鍙互甯姪浣犵籂姝i棶棰橈細
路 纭繚鏈嶅姟鍣ㄥ湪杩愯銆傚鏋滄湇鍔″櫒娌℃湁杩愯锛屽垯浣犱笉鑳借繛鎺ユ湇鍔″櫒銆傚鏋滀綘瑙嗗浘杩炴帴鏈嶅姟鍣ㄥ苟鐪嬪埌涓嬭堪娑堟伅锛屽彲鑳芥槸鏈嶅姟鍣ㄦ病鏈夎繍琛岋細
路 shell> mysql
路 ERROR 2003: Can't connect to MySQL server on 'host_name' (111)
路 shell> mysql
路 ERROR 2002: Can't connect to local MySQL server through socket
路 '/tmp/mysql.sock' (111)
涔熷彲鑳芥湇鍔″櫒姝e湪杩愯锛屼絾浣犲彲鑳戒娇鐢ㄤ笌鏈嶅姟鍣ㄤ笂渚﹀惉鐨勪笉涓鏍风殑TCP/IP绔彛銆佸懡鍚嶇閬撴垨Unix濂楁帴瀛楁枃浠躲備綘鍙互璋冪敤瀹㈡埛绔▼搴忥紝鎸囧畾绔彛閫夐」鏉ユ寚绀烘纭殑绔彛鎴栧鎺ュ瓧閫夐」鏉ユ寚绀烘纭殑鍛藉悕绠¢亾鎴Unix濂楁帴瀛楁枃浠躲傝鎵惧嚭濂楁帴瀛楁枃浠剁殑鍦扮偣锛屽簲锛
shell> netstat -ln | grep mysql
纭畾鏄惁瑕佸垵濮嬪寲鎺堟潈琛ㄧ殑涓涓柟娉曟槸瀵绘壘鏁版嵁鐩綍涓嬬殑mysql鐩綍锛鏁版嵁鐩綍鍚嶉氬父涓data鎴var锛屼綅浜MySQL瀹夎鐩綍涓锛銆傚簲淇濊瘉MySQL鏁版嵁搴撶洰褰曟湁鏂囦欢鈥user.MYD鈥銆傚惁鍒欙紝鎵цmysql_install_db鑴氭湰銆傝繍琛屽苟閲嶅惎鏈嶅姟鍣ㄥ悗锛屾墽琛岃鍛戒护鏉ユ祴璇曞垵濮嬫潈闄愶細
shell> mysql -u root test
鏈嶅姟鍣ㄥ簲璇ヨ浣犳棤璇湴杩炴帴銆
路 shell> mysql -u root mysql
鏈嶅姟鍣ㄥ簲璇ヨ浣犺繛鎺ワ紝鍥犱负MySQL root鐢ㄦ埛鍒濆鏃舵病鏈夊瘑鐮併傞偅涔熸槸瀹夊叏椋庨櫓锛屽綋浣犳鍦ㄨ缃叾浠MySQL鐢ㄦ埛鏃讹紝涔熷簲璁惧畾root瀵嗙爜鏄竴浠堕噸瑕佺殑浜嬭銆傚叧浜庤缃垵濮嬪瘑鐮佺殑璇存槑锛屽弬瑙2.9.3鑺傦紝鈥滀娇鍒濆MySQL璐︽埛瀹夊叏鈥銆
路 濡傛灉瀹㈡埛绔▼搴忚瘯鍥捐繛鎺ユ椂鏀跺埌浠ヤ笅閿欒淇℃伅锛岃鏄庢湇鍔″櫒闇瑕佹柊鏍煎紡鐨勫瘑鐮侊紝鑰屽鎴风涓嶈兘鐢熸垚锛
路 shell> mysql
路 Client does not support authentication protocol requested
路 by server; consider upgrading MySQL client
鍏充簬濡備綍澶勭悊鐨勮缁嗕俊鎭紝鍙傝5.7.9鑺傦紝鈥淢ySQL 4.1涓殑瀵嗙爜鍝堝笇澶勭悊鈥鍜A.2.3鑺傦紝鈥滃鎴风涓嶆敮鎸侀壌瀹氬崗璁銆
鍦ㄨ繖绉嶆儏鍐典笅锛屼綘蹇呴』鐢--skip-grant-tables閫夐」閲嶅惎鏈嶅姟鍣ㄥ苟涓旂紪杈鈥/etc/hosts鈥鎴鈥\windows\hosts鈥鏂囦欢涓轰綘鐨勪富鏈哄鍔犺銆
路 璁颁綇瀹㈡埛绔▼搴忎娇鐢ㄩ夐」鏂囦欢鎴栫幆澧冨彉閲忎腑鎸囧畾鐨勮繛鎺ュ弬鏁般傚鏋滃鎴风绋嬪簭鍙戦佷笉姝g‘鐨勯粯璁よ繛鎺ュ弬鏁帮紝鑰屼綘娌℃湁鍦ㄥ懡浠よ涓寚瀹氾紝妫鏌ョ幆澧冨彉閲忓拰閫傜敤鐨勯夐」鏂囦欢銆備緥濡傦紝褰撲綘涓嶇敤浠讳綍閫夐」杩愯瀹㈡埛绔▼搴忥紝寰楀埌Access denied閿欒锛岀‘淇濅綘娌℃湁鍦ㄩ夐」鏂囦欢涓寚瀹氭棫瀵嗙爜锛
浣犲彲浠ラ氳繃浣跨敤--no-defaults閫夐」璋冪敤瀹㈡埛绔▼搴忔潵绂佺敤閫夐」鏂囦欢銆備緥濡傦細
shell> mysqladmin --no-defaults -u root version
瀹㈡埛绔娇鐢ㄧ殑閫夐」鏂囦欢瑙4.3.2鑺傦紝鈥滀娇鐢ㄩ夐」鏂囦欢鈥銆傜幆澧冨彉閲忓垪浜闄勫綍F锛鐜鍙橀噺銆
路 濡傛灉閬囧埌涓嬭堪閿欒锛岃鏄root瀵嗙爜閿欒锛
路 shell> mysqladmin -u root -pxxxx ver
路 Access denied for user 'root'@'localhost' (using password: YES)
濡傛灉浣犳湭鎸囧畾瀵嗙爜鏃跺嚭鐜板墠闈㈢殑閿欒锛岃鏄庢煇涓夐」鏂囦欢涓殑瀵嗙爜涓嶆纭傝瘯璇曞墠闈㈡墍璇寸殑--no-defaults閫夐」銆
鍏充簬瀵嗙爜鏇存敼鐨勪俊鎭弬瑙5.8.5鑺傦紝鈥滆缃处鎴峰瘑鐮佲銆
濡傛灉浣犱涪澶辨垨蹇樿root瀵嗙爜锛屼綘鍙互鐢--skip-grant-tables閲嶅惎 mysqld鏉ユ洿鏀瑰瘑鐮併傚弬瑙A.4.1鑺傦紝鈥滃浣曞浣嶆牴鐢ㄦ埛瀵嗙爜鈥.
路 濡傛灉浣犱娇鐢SET PASSWORD銆INSERT鎴UPDATE鏇存敼瀵嗙爜锛屼綘蹇呴』浣跨敤 PASSWORD()鍑芥暟鍔犲瘑瀵嗙爜銆傚鏋滀綘涓嶄娇鐢PASSWORD()鍑芥暟锛屽瘑鐮佷笉宸ヤ綔銆備緥濡傦紝涓嬮潰鐨勮鍙ヨ缃瘑鐮侊紝浣嗘病鑳藉姞瀵嗭紝鍥犳鐢ㄦ埛鍚庨潰涓嶈兘杩炴帴锛
路 mysql> SET PASSWORD FOR 'abe'@'host_name' = 'eagle';
鐩稿弽锛屽簲杩欐牱璁剧疆瀵嗙爜锛
mysql> SET PASSWORD FOR 'abe'@'host_name' = PASSWORD('eagle');
褰撲綘浣跨敤GRANT鎴CREATE USER璇彞鎴mysqladmin password鍛戒护鎸囧畾瀵嗙爜鏃讹紝涓嶉渶瑕PASSWORD()鍑芥暟锛屽畠浠細鑷姩浣跨敤PASSWORD()鏉ュ姞瀵嗗瘑鐮併傚弬瑙5.8.5鑺傦紝鈥滆缃处鎴峰瘑鐮佲鍜13.5.1.1鑺傦紝鈥淐REATE USER璇硶鈥銆
路 localhost鏄綘鏈湴涓绘満鍚嶇殑涓涓悓涔夎瘝锛屽苟涓斾篃鏄鏋滀綘涓嶆槑纭湴鎸囧畾涓绘満鑰屽鎴风灏濊瘯杩炴帴鐨勯粯璁や富鏈恒
瑕佹兂鍦ㄨ繖绉嶇郴缁熶笂閬垮厤璇ラ棶棰橈紝浣犲彲浠ヤ娇鐢--host=127.0.0.1閫夐」鏉ユ槑纭懡鍚嶆湇鍔″櫒涓绘満銆傝繖鏍峰皢閫氳繃TCP/IP鍗忚鏉ヨ繛鎺ユ湰鍦mysqld鏈嶅姟鍣銆備綘杩樺彲浠ユ寚瀹--host閫夐」浣跨敤TCP/IP锛屼娇鐢ㄥ疄闄呯殑鏈満涓绘満鍚嶃傚湪杩欑鎯呭喌涓嬶紝涓绘満鍚嶅繀椤绘寚瀹氫负鏈嶅姟鍣ㄤ富鏈轰笂鐨user琛ㄨ锛屽嵆浣夸綘鍦ㄦ湇鍔″櫒涓婅繍琛屽鎴风绋嬪簭銆
路 褰撳皾璇曠敤mysql -u user_name涓庢暟鎹簱杩炴帴鏃讹紝濡傛灉浣犲緱鍒颁竴涓Access denied閿欒锛屽彲鑳戒細閬囧埌涓user琛ㄦ湁鍏崇殑闂锛岄氳繃鎵цmysql -u root mysql骞朵笖鎵ц涓嬮潰鐨SQL璇彞杩涜妫鏌ワ細
路 mysql> SELECT * FROM user;
缁撴灉搴旇鍖呭惈涓涓湁Host鍜User鍒楃殑琛屽尮閰嶄綘鐨勮绠楁満涓绘満鍚嶅拰浣犵殑MySQL鐢ㄦ埛鍚嶃
路 濡傛灉褰撲綘璇曠潃浠庝竴涓笉鏄MySQL鏈嶅姟鍣ㄦ鍦ㄨ繍琛岀殑涓绘満涓婅繛鎺ユ椂锛岄亣鍒颁笅鍒楅敊璇紝閭d箞鍦user琛ㄤ腑娌℃湁鍖归厤閭e彴涓绘満鐨勮锛
路 Host ... is not allowed to connect to this MySQL server
鍙互閫氳繃缁勫悎浣犳鍦ㄨ瘯鍥捐繛鎺ョ殑鐢ㄦ埛/涓绘満鍚嶈缃竴涓处鎴锋潵淇瀹冦傚鏋滀綘涓嶇煡閬撴杩炴帴鐨勬満鍣ㄧ殑IP鍙锋垨涓绘満鍚嶏紝搴旇鎶婁竴涓'%'琛屼綔涓Host鍒楀兼斁鍦user琛ㄤ腑銆傚湪璇曞浘浠庡鎴风鍣ㄨ繛鎺ヤ互鍚庯紝閫氳繃SELECT USER()鏌ヨ鏄剧ず浣犲浣曠湡姝h繘琛岃繛鎺ャ傦紙鐒跺悗鐢ㄥ湪鏃ュ織鏂囦欢涓婇潰鏄剧ず鍑虹殑瀹為檯鐨勪富鏈哄悕浠f浛user琛ㄤ腑鐨'%'琛屻傚惁鍒欙紝浣犲皢寰楀埌涓涓笉瀹夊叏鐨勭郴缁燂紝鍥犱负瀹冨厑璁镐粠浠讳綍涓绘満涓婁互浠讳綍鐢ㄦ埛鍚嶈繛鎺ャ傦級
鍦Linux涓紝鍙戠敓璇ラ敊璇殑鍙︿竴涓師鍥犲彲鑳芥槸浣犳浣跨敤浜庝綘鎵浣跨敤鐗堟湰鐨glibc搴撲笉鍚岀増鏈殑搴撶紪璇戠殑浜岃繘鍒MySQL鐗堟湰銆傚湪杩欑鎯呭喌涓嬶紝浣犲簲鍗囩骇鎿嶄綔绯荤粺鎴glibc锛屾垨涓嬭浇MySQL鐗堟湰鐨勬簮鐮佸垎鍙戠増骞惰嚜宸辩紪璇戙傛簮鐮RPM涓鑸緢瀹规槗缂栬瘧骞跺畨瑁咃紝鍥犳涓嶆槸澶ч棶棰樸
路 濡傛灉浣犺繛鎺ユ椂鎸囧畾涓绘満鍚嶏紝浣嗗緱鍒伴敊璇秷鎭富鏈哄悕鏈樉绀烘垨涓IP鍙凤紝琛ㄧず褰MySQL鏈嶅姟鍣ㄥ皢IP鍙疯В鏋愪负瀹㈡埛绔潵鍚嶆椂閬囧埌閿欒锛
路 shell> mysqladmin -u root -pxxxx -h some-hostname ver
路 Access denied for user 'root'@'' (using password: YES)
杩欒〃绀DNS闂銆傝鎯充慨澶嶏紝鎵цmysqladmin flush-hosts鏉ラ噸璁惧唴閮 DNS涓绘満鍚嶇紦瀛樸傚弬瑙7.5.6鑺傦紝鈥淢ySQL濡備綍浣跨敤DNS鈥銆
涓浜涘父鐢ㄧ殑瑙e喅鏂规鍖呮嫭锛
o 璇曡瘯鎵惧嚭DNS鏈嶅姟鍣ㄧ殑閿欒骞朵慨澶嶃
o 鍦MySQL鎺堟潈琛ㄤ腑鎸囧畾IP鍙疯屼笉鏄富鏈哄悕銆
o 鍦/etc/hosts涓斁鍏ュ鎴风鍚嶃
o 鐢--skip-name-resolve閫夐」鍚姩mysqld銆
o 鐢--skip-host-cache閫夐」鍚姩mysqld銆
o 鍦Unix涓紝濡傛灉浣犲湪鍚屼竴鍙版満鍣ㄤ笂杩愯鏈嶅姟鍣ㄥ拰瀹㈡埛绔紝杩炴帴鍒localhost銆傝繛鎺ュ埌鐨localhost鐨Unix杩炴帴浣跨敤Unix濂楁帴瀛楁枃浠惰屼笉鏄TCP/IP銆
o 鍦Windows涓紝浣犲湪鍚屼竴鍙版満鍣ㄤ笂杩愯鏈嶅姟鍣ㄥ拰瀹㈡埛绔苟涓旀湇鍔″櫒鏀寔鍛藉悕绠¢亾杩炴帴锛岃繛鎺ヤ富鏈哄悕(鍛ㄦ湡)銆傝繛鎺ヤ娇鐢ㄥ懡鍚嶇閬撹屼笉鏄TCP/IP銆
路 濡傛灉浣犲緱鍒颁笅鍒楅敊璇紝鍙互涓db鎴host琛ㄦ湁鍏筹細
路 Access to database denied
濡傛灉浠db琛ㄤ腑閫夋嫨浜嗗湪Host鍒楁湁绌哄肩殑鏉$洰锛屼繚璇佸湪host琛ㄤ腑鏈変竴涓垨澶氫釜鐩稿簲鐨勬潯鐩紝鎸囧畾db琛ㄤ腑鐨勬潯鐩傜敤鍝簺涓绘満銆
路 濡傛灉浣犺兘澶熻繛鎺MySQL鏈嶅姟鍣紝浣嗗鏋滃湪浣跨敤鍛戒护SELECT ... INTO OUTFILE鎴LOAD DATA INFILE璇彞鏃讹紝浣犲緱鍒Access denied閿欒锛屽湪user琛ㄤ腑鐨勬潯鐩彲鑳芥病鏈夊惎鐢FILE鏉冮檺銆
路 濡傛灉浣犵洿鎺ユ洿鏀规巿鏉冭〃(渚嬪锛屼娇鐢INSERT銆UPDATE鎴DELETE璇彞)骞朵笖浣犵殑鏇存敼濂藉儚琚拷鐣ヤ簡锛岃浣忎綘蹇呴』鎵цFLUSH PRIVILEGES璇彞鎴mysqladmin flush-privileges鍛戒护璁╂湇鍔″櫒鏉ラ噸璇绘巿鏉冭〃銆傚惁鍒欙紝鐩村埌鏈嶅姟鍣ㄤ笅娆¢噸鍚紝浣犵殑鏇存敼鏂规湁鏁堛傝浣忕敤UPDATE鍛戒护鏇存敼root瀵嗙爜鍚庯紝鍦ㄦ竻绌烘潈闄愬墠锛屼綘涓嶉渶瑕佹寚瀹氭柊瀵嗙爜锛屽洜涓烘湇鍔″櫒杩樹笉鐭ラ亾浣犲凡缁忔洿鏀逛簡瀵嗙爜锛
路 濡傛灉浣犵殑鏉冮檺浼间箮鍦ㄤ竴涓細璇濊繃绋嬩腑鏀瑰彉浜嗭紝鍙兘鏄竴涓秴绾х敤鎴锋敼鍙樹簡浠栦滑銆傚啀娆¤鍏ユ巿鏉冭〃浼氬奖鍝嶆柊瀹㈡埛绔繛鎺ワ紝浣嗘槸瀹冧篃褰卞搷鐜板瓨鐨勮繛鎺ワ紝濡5.7.7鑺傦紝鈥滄潈闄愭洿鏀逛綍鏃剁敓鏁堚灏忚妭鎵杩般
路 濡傛灉浣犳湁Perl銆Python鎴ODBC绋嬪簭鐨勫瓨鍙栭棶棰橈紝璇曠潃鐢mysql -u user_name db_name鎴mysql -u user_name -pyour_pass db_name涓庢湇鍔″櫒杩炴帴銆傚鏋滀綘鑳界敤mysql瀹㈡埛绔繘琛岃繛鎺ワ紝杩欐槸绋嬪簭鐨勪竴涓棶棰樿屼笉鏄闂潈闄愮殑闂銆傦紙娉ㄦ剰鍦-p鍜屽瘑鐮佷箣闂存病鏈夌┖鏍硷紱涔熷彲浠ヤ娇鐢--password=your_pass璇硶鎸囧畾瀵嗙爜銆傚鏋滀娇鐢-p閫夐」锛MySQL鎻愮ず浣犺緭鍏ュ瘑鐮併傦級
路 涓轰簡娴嬭瘯锛岀敤--skip-grant-tables閫夐」鍚姩mysqld瀹堟姢杩涚▼锛岀劧鍚庝綘鍙互鏀瑰彉MySQL鎺堟潈琛ㄥ苟涓斾娇鐢mysqlaccess鑴氭湰妫鏌ヤ綘鐨勪慨鏀规槸鍚︽湁濡傛湡鐨勬晥鏋溿傚綋浣犲浣犵殑鏀瑰彉婊℃剰鏃讹紝鎵цmysqladmin flush-privileges鍛婅瘔mysqld鏈嶅姟鍣ㄥ紑濮嬩娇鐢ㄦ柊鐨 鎺堟潈琛ㄣ傦紙鍐嶆瑁呭叆鎺堟潈琛ㄨ鐩栦簡--skip-grant-tables閫夐」銆傝繖鍏佽浣犲憡璇夋湇鍔″櫒寮濮嬩娇鐢ㄦ巿鏉冭〃锛岃屼笉鐢ㄥ仠鎺夊苟閲嶅惎瀹冿級銆
路 濡傛灉浠讳綍鍏跺畠浜嬫儏澶辫触锛岀敤璋冭瘯閫夐」(渚嬪锛--debug=d,general,query)鍚姩mysqld鏈嶅姟鍣ㄣ傝繖灏嗘墦鍗版湁鍏冲皾璇曡繛鎺ョ殑涓绘満鍜岀敤鎴蜂俊鎭紝鍜屽彂鍑虹殑姣忎釜鍛戒护鐨勪俊鎭傝鍙傝E.1.2鑺傦紝鈥滃垱寤鸿窡韪枃浠垛銆
路 濡傛灉浣犳湁浠讳綍涓MySQL鎺堟潈琛ㄧ殑鍏跺畠闂锛岃屼笖瑙夊緱浣犲繀椤诲皢杩欎釜闂鍙戦佸埌閭欢琛紝涓瀹氳鎻愪緵涓涓MySQL鎺堟潈琛ㄧ殑鍊惧掑壇鏈(dump)銆備綘鍙敤mysqldump mysql鍛戒护澶嶅埗鏁版嵁搴撹〃銆傝薄骞虫椂涓鏍凤紝鐢mysqlbug鑴氭湰閭瘎浣犵殑闂銆傚弬瑙1.7.1.3鑺傦紝鈥滃浣曢氭姤缂洪櫡鍜岄棶棰樷銆傚湪涓浜涙儏鍐典笅鍙互鐢--skip-grant-tables閲嶅惎mysqld浠ヤ究鑳借繍琛mysqldump銆
MySQL鐢ㄦ埛璐︽埛鍒椾簬mysql鏁版嵁搴撲腑鐨user琛ㄥ唴銆傛瘡涓MySQL璐︽埛鎸囧畾涓涓瘑鐮侊紝灏界淇濆瓨鍦user琛Password鍒楃殑瀵嗙爜涓嶆槸鏄庢枃锛屼絾鍝堝笇鍊兼槸浠庤〃涓殑璁板綍璁$畻鐨勩傜敤PASSWORD()鍑芥暟鏉ヨ绠楀瘑鐮佺殑鍝堝笇鍊笺
MySQL鍦ㄥ鎴风/鏈嶅姟鍣ㄩ氫俊鐨勪袱涓樁娈典娇鐢ㄥ瘑鐮侊細
路 濡傛灉瀹㈡埛绔瘯鍥捐繛鎺ユ湇鍔″櫒锛屾湁涓涓垵濮嬮壌瀹氭楠わ紝瀹㈡埛蹇呴』鎻愪緵涓涓瘑鐮侊紝骞朵笖蹇呴』涓庡鎴锋兂瑕佷娇鐢ㄧ殑璐︽埛鍦user琛ㄤ繚瀛樼殑鍝堝笇鍊煎尮閰嶃
路 瀹㈡埛绔繛鎺ュ悗锛屽畠鍙互(濡傛灉鏈夊厖鍒嗙殑鏉冮檺) 璁剧疆鎴栨洿鏀user琛ㄥ唴鎵鍒楃殑璐︽埛鐨勫瘑鐮佸搱甯屽煎笺傚鎴风鍙互閫氳繃PASSWORD()鍑芥暟鏉ョ敓鎴愬瘑鐮佸搱甯屽硷紝鎴栦娇鐢GRANT鎴SET PASSWORD璇彞銆
鎹㈠彞璇濊锛屽綋瀹㈡埛绔娆¤瘯鍥捐繛鎺ユ椂锛屾湇鍔″櫒浣跨敤鍝堝笇鍊艰繘琛岄壌瀹氥傚鏋滆繛鎺ョ殑瀹㈡埛绔皟鐢PASSWORD()鍑芥暟鎴栦娇鐢GRANT鎴SET璇彞鏉ヨ缃垨鏇存敼瀵嗙爜锛屽垯鏈嶅姟鍣浜х敓鍝堝笇鍊笺
鍦MySQL 4.1涓瘑鐮佸搱甯岀畻娉曞凡缁忔洿鏂帮紝鎻愪緵浜嗘洿濂界殑瀹夊叏鎬у苟闄嶄綆浜嗗瘑鐮佽鎴彇鐨勯闄┿備絾鏄紝璇ユ柊鏈哄埗鍙兘鍦MySQL 4.1(鍜屾洿鏂扮増鏈殑)鏈嶅姟鍣ㄥ拰瀹㈡埛绔腑浣跨敤锛屼細浜х敓涓浜涘吋瀹规ч棶棰樸4.1鎴栨柊瀹㈡埛绔彲浠ヨ繛鎺4.1涔嬪墠鐨勬湇鍔″櫒锛屽洜涓哄鎴风鍙互鍚屾椂鐞嗚В鏃х殑鍜屾柊鐨勫瘑鐮佸搱甯屾満鍒躲備絾鏄紝4.1涔嬪墠鐨勫鎴风璇曞浘杩炴帴4.1鐗堟垨鏇存柊鐗堢殑鏈嶅姟鍣ㄦ椂浼氶亣鍒板洶闅俱備緥濡傦紝3.23鐗mysql瀹㈡埛绔瘯鍥捐繛鎺5.1鏈嶅姟鍣ㄦ椂浼氬け璐ュ苟鍑虹幇涓嬮潰鐨勯敊璇秷鎭細
shell> mysql -h localhost -u root
Client does not support authentication protocol requested
by server; consider upgrading MySQL client
鍑虹幇璇ラ棶棰樼殑鍙︿竴涓櫘閫氫緥瀛愭槸鍦ㄥ崌绾у埌MySQL 4.1鎴栨洿鏂扮増鍚庯紝璇曞浘浣跨敤鏃х増鏈殑PHP mysql鎵╁睍鍚嶃(鍙傝25.3.1鑺傦紝鈥滀娇鐢∕ySQL鍜孭HP鐨勫父瑙侀棶棰樷锛銆
涓嬮潰璁ㄨ浜嗘柊銆佹棫瀵嗙爜鏈哄埗涔嬮棿鐨勫樊鍒紝浠ュ強濡傛灉浣犲崌绾т簡鏈嶅姟鍣ㄤ絾闇瑕佷负4.1鐗堜互鍓嶇殑瀹㈡埛绔繚鎸佸悜鍚庡吋瀹规ц鎬庢牱鍋氥A.2.3鑺傦紝鈥滃鎴风涓嶆敮鎸侀壌瀹氬崗璁涓湁鏇磋缁嗙殑淇℃伅銆傝淇℃伅灏MySQL鏁版嵁搴撲粠4.0鐗堟湰鎴栨洿浣庣増鍗囩骇鍒4.1鐗堟垨鏇撮珮鐗堢殑PHP缂栫▼浜哄憳鐗瑰埆閲嶈銆
娉閲婏細璇ヨ璁哄姣斾簡4.1鐗堢殑琛屼负鍜4.1鍓嶇殑琛屼负锛岃繖鍎挎弿杩扮殑4.1涓殑琛屼负瀹為檯涓婁粠4.1.1寮濮嬨MySQL 4.1.0鏄竴涓滄棫鈥濈殑鍙戝竷锛屽洜涓哄畠鐨勫疄鏂芥満鍒朵笌4.1.1鐗堝拰鏇存柊鐗堜腑鐨勭◢鏈変笉鍚屻傚湪MySQL 5.0 鍙傝冩墜鍐屼腑璇︾粏鎻忚堪浜4.1.0鍜屾渶鏂扮増涔嬮棿鐨勫樊鍒
鍦MySQL 4.1涔嬪墠,鐢PASSWORD()鍑芥暟璁$畻鐨勫瘑鐮佸搱甯屽兼湁16涓瓧鑺傞暱銆傚簲涓猴細
mysql> SELECT PASSWORD('mypass');
+--------------------+
| PASSWORD('mypass') |
+--------------------+
| 6f8c114b58f2ce9e |
+--------------------+
鍦MySQL 4.1涔嬪墠锛user琛ㄧ殑Password鍒(淇濆瓨浜嗗搱甯屽)涔熸槸16瀛楄妭闀裤
鍦MySQL 4.1涓,宸茬粡瀵PASSWORD()鍑芥暟杩涜浜嗕慨鏀癸紝鍙互鐢熸垚41瀛楄妭鐨勫搱甯屽硷細
mysql> SELECT PASSWORD('mypass');
+-------------------------------------------+
| PASSWORD('mypass') |
+-------------------------------------------+
| *6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4 |
+-------------------------------------------+
鍚屾牱锛user琛ㄧ殑Password鍒楀繀椤绘湁41瀛楄妭闀挎潵淇濆瓨杩欎簺鍊硷細
路 濡傛灉浣犳柊瀹夎MySQL 5.1, Password鍒楄嚜鍔ㄤ负41瀛楄妭闀裤
路 浠MySQL 4.1(4.1.1鎴4.1绯诲垪鐨勬洿鏂扮増)鍗囩骇鍒MySQL 5.1锛屽簲涓嶄細鍑虹幇鐩稿叧闂锛屽洜涓轰袱涓増鏈娇鐢ㄧ浉鍚岀殑瀵嗙爜鍝堝笇鏈哄埗銆傚鏋滀綘鎯宠灏嗘洿鏃╃増鏈殑MySQL鍗囩骇鍒MySQL5.1,浣犲簲鍏堝崌绾у埌4.1锛岀劧鍚庡皢4.1鍗囩骇鍒5.1銆
鍔犲鐨Password鍒楀彲浠ュ悓鏃朵繚瀛樻柊銆佹棫鏍煎紡鐨勫瘑鐮佸搱甯屽笺傚彲浠ユ湁涓ょ鏂瑰紡纭畾浠讳綍缁欏畾鏍煎紡鐨勫瘑鐮佸搱甯屽硷細
路 鏄庢樉鐨勪笉鍚屼箣澶勬槸闀垮害(16瀛楄妭鍜41瀛楄妭)銆
路 绗2涓笉鍚屼箣澶勬槸鏂版牸寮忕殑瀵嗙爜鍝堝笇鍊奸兘浠モ*鈥欏瓧绗﹀紑澶达紝鑰屾棫鏍煎紡鐨勫瘑鐮佺粷瀵逛笉鏄
闀垮瘑鐮佸搱甯屽煎叿鏈夋洿濂界殑鍔犲瘑灞炴э紝骞朵笖瀹㈡埛绔牴鎹暱鍝堝笇鍊艰繘琛岄壌瀹氭瘮鏃х殑鐭搱甯屽兼洿鍔犲畨鍏ㄣ
鐭瘑鐮佸搱甯屽煎拰闀垮瘑鐮佸搱甯屽间箣闂寸殑涓嶅悓涔嬪涓庢湇鍔″櫒濡備綍浣跨敤瀵嗙爜杩涜閴村畾浠ュ強濡備綍涓烘墽琛屽瘑鐮佹洿鏀规搷浣滅殑杩炴帴鐨勫鎴风鐢熸垚瀵嗙爜鍝堝笇鍊奸兘鏈夊叧銆
鏈嶅姟鍣ㄤ娇鐢ㄥ瘑鐮佸搱甯屽艰繘琛岄壌瀹氱殑鏂瑰紡鍙Password鍒楃殑瀹藉害褰卞搷锛
路 濡傛灉鍒楄緝鐭紝鍙敤鐭搱甯岄壌瀹氥
路 濡傛灉鍒楄緝闀匡紝鍙互鏈夌煭鎴栭暱鍝堝笇鍊硷紝骞朵笖鏈嶅姟鍣ㄥ彲浠ヤ娇鐢ㄤ换浣曚竴绉嶆牸寮忥細
o 4.1涔嬪墠鐨勫鎴风鍙互杩炴帴锛屽畠浠彧鍙互浣跨敤鏃х殑鍝堝笇鏈哄埗锛屽畠浠彲浠ュ彧閴村畾鏈夌煭鍝堝笇鐨勮处鎴枫
o 4.1鍙婁互鍚庣増鏈殑瀹㈡埛绔彲浠ラ壌瀹氭湁鐭搱甯屾垨闀垮搱甯岀殑璐︽埛銆
瀵逛簬鐭搱甯岃处鎴风殑閴村畾杩囩▼锛4.1鍜屼互鍚庣増鏈殑瀹㈡埛绔瘮涓烘棫鐗堟湰鐨勫鎴风瀹為檯瑕佸畨鍏ㄥ緱澶氥備粠瀹夊叏鎬ц搴︼紝浠庢渶浣庡畨鍏ㄥ埌鏈瀹夊叏鐨勬搴︿负锛
路 4.1涔嬪墠鐨勫鎴风鐢ㄧ煭瀵嗙爜鍝堝笇鍊艰繘琛岄壌瀹
路 4.1鎴栦互鍚庣増鏈殑瀹㈡埛绔敤鐭瘑鐮佸搱甯屽艰繘琛岄壌瀹
路 4.1鎴栦互鍚庣増鏈殑瀹㈡埛绔敤闀垮瘑鐮佸搱甯屽艰繘琛岄壌瀹
鏈嶅姟鍣ㄤ负杩炴帴鐨勫鎴风鐢熸垚瀵嗙爜鍝堝笇鍊肩殑鏂瑰紡鍙Password鍒楀搴﹀拰--old-passwords閫夐」鐨勫奖鍝嶃4.1鎴栨洿鏂扮増鏈殑鏈嶅姟鍣ㄥ彧鏈夋弧瓒虫煇涓潯浠舵墠鐢熸垚闀垮搱甯岋細Password鍒楀繀椤昏冻澶熷浠ュ绾抽暱鍝堝笇鍊煎苟涓旀湭缁欏畾--old-passwords閫夐」銆傝繖浜涙潯浠堕傚悎锛
路 Password鍒楀繀椤昏冻澶熷浠ュ绾抽暱鍝堝笇(41瀛楄妭)鍊笺傚鏋滃垪娌℃湁鏇存柊锛屼粛鐒朵负4.1涔嬪墠鐨16瀛楄妭瀹斤紝褰撳鎴风浣跨敤PASSWORD()銆GRANT鎴SET PASSWORD鎵ц瀵嗙爜鏇存敼鎿嶄綔鏃讹紝鏈嶅姟鍣ㄦ敞鎰忓埌闀垮搱甯屼笉閫傚悎锛屽彧鐢熸垚鐭搱甯屻傚鏋滀綘宸茬粡鍗囩骇鍒4.1浣嗚繕娌℃湁杩愯 mysql_fix_privilege_tables鑴氭湰鏉ユ墿瀹Password鍒楁椂浼氬嚭鐜拌繖绉嶈涓恒
路 濡傛灉Password鍒楄冻澶熷锛屽垯鍙互淇濆瓨鐭垨闀垮瘑鐮佸搱甯屽笺傚湪杩欑鎯呭喌涓嬶紝PASSWORD()銆GRANT鎴SET PASSWORD鐢熸垚闀垮搱甯岋紝闄ら潪 鐢--old-passwords閫夐」鍚姩鏈嶅姟鍣ㄣ傝閫夐」寮哄埗鏈嶅姟鍣ㄧ敓鎴愮煭瀵嗙爜鍝堝笇鍊笺
--old-passwords閫夐」鐨勭洰鐨勬槸褰撴湇鍔″櫒鐢熸垚闀垮瘑鐮佸搱甯屽兼椂锛屽厑璁镐綘缁存寔鍚4.1涔嬪墠鐨勫鎴风鐨勫悜鍚庡吋瀹规с傝閫夐」涓嶅奖鍝嶉壌瀹(4.1鍜屼互鍚庣増鏈殑瀹㈡埛绔粛鐒跺彲浠ヤ娇鐢ㄦ湁闀垮瘑鐮佸搱甯屽肩殑璐︽埛)锛屼絾瀹冮槻姝㈠湪瀵嗙爜鏇存敼鎿嶄綔涓湪user琛ㄤ腑鍒涘缓闀垮瘑鐮佸搱甯屽笺傚湪杩欑鎯呭喌涓嬶紝璇ヨ处鎴蜂笉鑳藉啀鐢ㄤ簬4.1涔嬪墠鐨勫鎴风銆傛病鏈--old-passwords閫夐」锛屽彲鑳戒細鍑虹幇涓嬮潰鐨勪笉鏈熸湜鐨勬儏鍐碉細
路 鏃у鎴风杩炴帴鏈夌煭瀵嗙爜鍝堝笇鍊肩殑璐︽埛銆
路 瀹㈡埛鏇存敼鑷繁鐨勫瘑鐮併傛病鏈--old-passwords锛屽彲浠ヤ负璇ヨ处鎴风敓鎴愰暱瀵嗙爜鍝堝笇鍊笺
路 涓嬫鏃у鎴疯瘯鍥捐繛鎺ヨ处鎴锋椂涓嶈兘杩炴帴涓婏紝鍥犱负璐︽埛鏈夐暱瀵嗙爜鍝堝笇鍊硷紝闇瑕佹柊鐨勫搱甯屾満鍒惰繘琛岄壌瀹氥(涓鏃﹁处鎴user琛ㄤ腑涓洪暱瀵嗙爜鍝堝笇鍊硷紝鍙湁4.1鍜屼互鍚庣増鏈殑瀹㈡埛绔彲浠ラ壌瀹氬畠锛屽洜涓4.1涔嬪墠鐨勫鎴风涓嶇悊瑙i暱鍝堝笇锛銆
璇ュ満鏅鏄庯紝濡傛灉浣犲繀椤绘敮鎸佹棫鐨4.1涔嬪墠鐨勫鎴风锛屼笉浣跨敤--old-passwords閫夐」杩愯4.1鎴栨洿鏂扮増鏈殑鏈嶅姟鍣ㄥ緢鍗遍櫓銆傜敤--old-passwords杩愯鏈嶅姟鍣紝瀵嗙爜鏇存敼鎿嶄綔涓嶄細鐢熸垚闀垮瘑鐮佸搱甯屽硷紝杩欐牱鏃у鎴风涔熷彲浠ヨ闂处鎴枫(杩欎簺瀹㈡埛绔笉鑳芥剰澶栧湴鍥犳洿鏀逛簡瀵嗙爜灏嗚嚜宸遍攣鍑哄幓锛屽苟鐣欎笅闀垮瘑鐮佸搱甯屽硷級銆
--old-passwords閫夐」鐨勪笉鍒╀箣澶勬槸浣犲垱寤烘垨鏇存敼鐨勫瘑鐮佷娇鐢ㄧ煭鍝堝笇锛岀敋鑷冲浜4.1瀹㈡埛绔篃濡傛銆傝繖鏍凤紝浣犱涪澶变簡闀垮瘑鐮佸搱甯屽兼彁渚涚殑瀹夊叏鎬с傚鏋滀綘鎯宠鍒涘缓鏈夐暱鍝堝笇鐨勮处鎴(渚嬪锛屼负4.1瀹㈡埛绔)锛屼綘蹇呴』涓嶄娇鐢--old-passwords鏉ヨ繍琛屾湇鍔″櫒銆
涓嬮潰鐨勫満鏅彲鐢ㄤ簬杩愯4.1鎴栦互鍚庣殑鏈嶅姟鍣紝鍖呮嫭MySQL 5.1锛
鍦烘櫙1锛user琛ㄤ腑鐨勭煭Password鍒楋細
路 鍙湁鐭搱甯屽彲浠ヤ繚瀛樺埌Password鍒椼
路 鏈嶅姟鍣ㄥ彧浣跨敤鐭搱甯岃繘琛屽鎴风閴村畾銆
路 瀵逛簬杩炴帴鐨勫鎴风锛岃皟鐢PASSWORD()銆GRANT鎴SET PASSWORD鐨勫瘑鐮佸搱甯岀敓鎴愭搷浣滀笓浣跨敤鐭搱甯屻傚璐︽埛鐨勪换浣曟洿鏀瑰潎浼氱敓鎴愮煭瀵嗙爜鍝堝笇鍊笺
路 --old-passwords閫夐」鍙互浣跨敤浣嗘槸澶氫綑锛屽洜涓Password鍒楄緝鐭紝鏈嶅姟鍣ㄥ彧鐢熸垚鐭瘑鐮佸搱甯屽笺
鍦烘櫙2锛闀Password鍒楋紱娌℃湁鐢--old-passwords閫夐」鍚姩鏈嶅姟鍣細
路 鐭垨闀垮搱甯屽彲浠ヤ繚瀛樺埌Password鍒椼
路 4.1鍜屼互鍚庣増鏈殑瀹㈡埛绔(鍖呮嫭5.1瀹㈡埛绔)鍙互閴村畾鏈夌煭鎴栭暱鍝堝笇鐨勮处鎴枫
路 4.1涔嬪墠鐨勫鎴风鍙兘閴村畾鏈夌煭鍝堝笇鐨勮处鎴枫
路 瀵逛簬杩炴帴鐨勫鎴风锛岃皟鐢PASSWORD()銆GRANT鎴SET PASSWORD鐨勫瘑鐮佸搱甯岀敓鎴愭搷浣滀笓浣跨敤鐭搱甯屻傚璐︽埛鐨勪换浣曟洿鏀瑰潎浼氱敓鎴愮煭瀵嗙爜鍝堝笇鍊笺
濡傚墠闈㈡墍绀猴紝璇ュ満鏅殑鍗遍櫓鎬у湪浜4.1涔嬪墠鐨勫鎴风鍙兘涓嶈兘璁块棶鏈夌煭瀵嗙爜鍝堝笇鍊肩殑璐︽埛銆傞氳繃PASSWORD()銆GRANT鎴SET PASSWORDA瀵硅繖浜涜处鎴峰瘑鐮佺殑鏇存敼浼氫骇鐢熼暱鐨勫瘑鐮佸搱甯屽笺備粠璇ョ偣鐪嬶紝4.1涔嬪墠鐨勫鎴风鍗囩骇鍒4.1涔嬪墠涓嶈兘閴村畾璇ヨ处鎴枫
瑕佸鐞嗚闂锛屽彲浠ョ敤鐗规畩鏂规硶鏇存敼瀵嗙爜銆備緥濡傦紝涓鑸儏鍐典綘鍙互浣跨敤SET PASSWORD鎸夌収涓嬮潰鐨勬柟娉曟洿鏀硅处鎴峰瘑鐮侊細
mysql> SET PASSWORD FOR 'some_user'@'some_host' = PASSWORD('mypass');
瑕佹兂鏇存敼瀵嗙爜浣嗗垱寤虹煭鍝堝笇锛屼娇鐢OLD_PASSWORD()鍑芥暟锛
mysql> SET PASSWORD FOR 'some_user'@'some_host' = OLD_PASSWORD('mypass');
褰撲綘鎯虫槑鏄剧敓鎴愮煭鍝堝笇鏃锛OLD_PASSWORD()寰堟湁鐢ㄣ
鍦烘櫙3锛闀Password鍒楋紱鐢--old-passwords閫夐」鍚姩4.1鎴栨柊鐗堟湰鐨勬湇鍔″櫒锛
路 鐭垨闀垮搱甯屽彲浠ヤ繚瀛樺埌Password鍒椼
路 4.1鍜屼互鍚庣増鏈殑瀹㈡埛绔彲浠ラ壌瀹氭湁鐭垨闀垮搱甯岀殑璐︽埛(璇锋敞鎰忓彧鏈変笉浣跨敤--old-passwords閫夐」鍚姩鏈嶅姟鍣紝鏂瑰彲浠ュ垱寤洪暱鍝堝笇)銆
路 4.1涔嬪墠鐨勫鎴风鍙彲浠ラ壌瀹氱煭鍝堝笇璐︽埛銆
路 瀵逛簬杩炴帴鐨勫鎴风锛岃皟鐢PASSWORD()銆GRANT鎴SET PASSWORD鐨勫瘑鐮佸搱甯岀敓鎴愭搷浣滀笓浣跨敤鐭搱甯屻傚璐︽埛鐨勪换浣曟洿鏀瑰潎浼氱敓鎴愮煭瀵嗙爜鍝堝笇鍊笺
鍦ㄨ鍦烘櫙涓紝浣犱笉鑳藉垱寤洪暱瀵嗙爜鍝堝笇鍊肩殑璐︽埛锛屽洜涓--old-passwords閫夐」闃叉鐢熸垚闀垮搱甯屻傚苟涓旓紝濡傛灉浣犲湪浣跨敤--old-passwords閫夐」鍓嶅垱寤洪暱鍝堝笇璐︽埛锛屽綋--old-passwords鏈夋椂鏇存敼璐︽埛瀵嗙爜锛岀粨鏋滀細浣胯处鎴风殑瀵嗙爜涓虹煭瀵嗙爜锛屽畨鍏ㄦц緝闀垮搱甯岃闄嶄綆銆
杩欎簺鍦烘櫙鐨勪笉鍒╀箣澶勫彲浠ユ鎷负锛
鍦ㄥ満鏅1涓,浣犱笉鑳藉埄鐢ㄩ暱鍝堝笇鎻愪緵鏇村畨鍏ㄧ殑閴村畾銆
鍦ㄥ満鏅2涓, 濡傛灉浣犳病鏈夋樉寮忎娇鐢OLD_PASSWORD()鏉ユ洿鏀瑰瘑鐮侊紝鍒4.1涔嬪墠鐨勫鎴风涓嶈兘鍐嶈闂煭鍝堝笇璐︽埛銆
鍦ㄥ満鏅3涓,--old-passwords闃叉鐭搱甯岃处鎴蜂笉鍙闂紝浣嗗瘑鐮佹洿鏀规搷浣滀娇璐︽埛鐨勯暱鍝堝笇杞崲涓虹煭鍝堝笇锛屽綋--old-passwords鏈夋晥鏃朵笉鑳藉皢瀹冩敼鍥為暱鍝堝笇銆
鍗囩骇鍒MySQL4.1鎴栨洿鏂扮増鏈悗锛屼娇鐢PASSWORD()涓鸿嚜宸辩殑鐩殑鐢熸垚瀵嗙爜鐨勫簲鐢ㄧ▼搴忎細鍑虹幇鍏煎鎬ч棶棰樸傚簲鐢ㄧ▼搴忓疄闄呬笉搴旇繖鏍峰仛锛屽洜涓PASSWORD()鍙簲鐢ㄦ潵绠$悊MySQL璐︽埛鐨勫瘑鐮併備絾涓浜涘簲鐢ㄧ▼搴忎娇鐢PASSWORD()鐢ㄤ簬鑷繁鐨勭洰鐨勩
濡傛灉浣犱粠MySQL 4.1涔嬪墠鐨勭増鏈崌绾у埌4.1鎴栦互鍚庣増鏈紝骞跺湪鐢熸垚闀垮瘑鐮佸搱甯屽肩殑鏉′欢涓嬭繍琛屾湇鍔″櫒锛屽簲鐢ㄧ▼搴忎娇鐢PASSWORD()鐮磋В鑷繁鐨勫瘑鐮併傝繖绉嶆儏鍐典笅鎺ㄨ崘鐨勬柟娉曟槸淇敼搴旂敤绋嬪簭锛屼娇鐢ㄥ叾瀹冨嚱鏁帮紝渚嬪SHA1()鎴MD5()锛屾潵浜х敓鍝堝笇鍊笺傚鏋滀笉琛岋紝浣犲彲浠ヤ娇鐢OLD_PASSWORD()鍑芥暟锛岃鍑芥暟鐢ㄦ潵鎻愪緵鏃ф牸寮忕殑鐭搱甯屻備絾鏄紝璇锋敞鎰OLD_PASSWORD()鍙兘鏈変竴澶╀笉鍐嶈鏀寔銆
濡傛灉鏈嶅姟鍣ㄨ繍琛屽湪鐢熸垚鐭搱甯岀殑鏉′欢涓嬶紝鍙互浣跨敤 OLD_PASSWORD()浣嗕笌PASSWORD()绛夊悓銆
灏MySQL鏁版嵁搴撲粠4.0鎴栨洿浣庣増鏈Щ妞嶅埌4.1鎴栨洿楂樼増鏈殑PHP缂栫▼浜哄憳搴斿弬闃鏃у鎴风銆
鏈妭鎻忚堪濡備綍涓MySQL鏈嶅姟鍣ㄧ殑瀹㈡埛绔缃处鎴枫傝璁轰簡涓嬮潰鐨勪富棰橈細
路 MySQL浣跨敤鐨勮处鎴峰悕鍜屽瘑鐮佺殑鍚箟锛屼互鍙婂浣曟瘮杈冧綘鐨勬搷浣滅郴缁熸墍浣跨敤鐨勮处鎴峰悕鍜屽瘑鐮
路 濡備綍璁剧疆鏂拌处鎴峰苟绉婚櫎宸叉湁璐︽埛
路 濡備綍鏇存敼瀵嗙爜
路 瀹夊叏浣跨敤瀵嗙爜鎸囧
路 濡備綍浣跨敤瀹夊叏SSL杩炴帴
鐢ㄧ敤鎴峰悕鍜屽鎴风鎴栦富鏈哄畾涔MySQL璐︽埛锛岀敤鎴峰彲浠ユ牴鎹繖浜涘悕绉版潵杩炴帴鏈嶅姟鍣ㄣ傝处鎴蜂篃鏈夊瘑鐮併MySQL鍜屾搷浣滅郴缁熶娇鐢ㄧ敤鎴峰悕鍜屽瘑鐮佺殑鏂瑰紡鏈夊嚑澶勫尯鍒細
路 MySQL鐢ㄤ簬閴村畾鐩殑鐢ㄦ埛鍚嶄笌Windows鎴Unix浣跨敤鐨勭敤鎴峰悕(鐧诲綍鍚)娌℃湁鍏崇郴銆傚湪Unix涓紝澶у鏁MySQL瀹㈡埛绔粯璁よ瘯鍥句娇鐢ㄥ綋鍓Unix鐨勭敤鎴峰悕浣滀负MySQL鐢ㄦ埛鍚嶆潵鐧诲綍锛屼絾杩欐牱鍙槸涓轰簡鏂逛究銆 榛樿鍊煎彲浠ュ緢瀹规槗琚鐩栵紝鍥犱负瀹㈡埛绔▼搴忓厑璁哥敤-u鎴--user閫夐」鏉ユ寚瀹氱敤鎴峰悕銆傚洜涓鸿繖琛ㄧず浠讳綍浜哄彲浠ヨ瘯鍥句娇鐢ㄤ换浣曠敤鎴峰悕鏉ヨ繛鎺ユ湇鍔″櫒锛岄櫎闈炴墍鏈MySQL璐︽埛鏈夊瘑鐮侊紝鍚﹀垯浣犱笉鑳戒娇鏁版嵁搴撲繚鎸佸畨鍏ㄣ傞氳繃涓烘病鏈夊瘑鐮佺殑璐︽埛鎸囧畾鐢ㄦ埛鍚嶏紝浠讳綍浜鸿兘澶熸垚鍔熻繛鎺ユ湇鍔″櫒銆
路 MySQL鐢ㄦ埛鍚嶆渶澶у杈16瀛楃闀裤傝繖鏍峰彲浠ラ檺鍒MySQL鏈嶅姟鍣ㄥ拰瀹㈡埛绔箣闂寸殑纭紪鐮侊紝骞朵笖闃叉閫氳繃淇敼mysql鏁版嵁搴撲腑琛ㄧ殑瀹氫箟鏉ュ伔绐冨瘑鐮併
娉:浣搴旂粷瀵逛笉瑕佷互浠讳綍鏂瑰紡淇敼mysql鏁版嵁搴撲腑鐨勪换浣曡〃锛屽彧鑳借繍琛MySQL鍒嗗彂涓笓涓烘鐩殑鎻愪緵鐨勮剼鏈傚皢MySQL绯荤粺琛ㄩ噸鏂板畾涔変负鍏跺畠鏂瑰紡浼氬鑷存湭瀹氫箟鐨(鍜屼笉鏀寔鐨!)琛屼负銆
鎿嶄綔绯荤粺鐢ㄦ埛鍚嶄笌MySQL鐢ㄦ埛鍚嶅畬鍏ㄤ笉鐩稿叧锛岀敋鑷虫渶澶ч暱搴﹀彲鑳戒笉鍚屻備緥濡傦紝 Unix鐢ㄦ埛鍚嶉檺鍒朵负8涓瓧绗︺
路 MySQL瀵嗙爜涓庣櫥褰曞埌浣犵殑鎿嶄綔绯荤粺鐨勫瘑鐮佹病鏈夊叧绯汇備笉闇瑕佸皢浣犵敤鏉ョ櫥褰Windows鎴Unix鏈哄櫒鐨勫瘑鐮佸拰浣犵敤鏉ヨ闂鏈哄櫒涓婄殑MySQL鏈嶅姟鍣ㄧ殑瀵嗙爜鍏宠仈璧锋潵銆
路 MySQL鐨勫姞瀵嗗瘑鐮佷娇鐢ㄨ嚜宸辩殑绠楁硶銆傝鍔犲瘑绠楁硶涓嶅悓浜Unix鐧诲綍杩囩▼浣跨敤鐨勭畻娉曘MySQL瀵嗙爜鍔犲瘑涓PASSWORD()SQL鍑芥暟鐨勬柟娉曠浉鍚屻Unix瀵嗙爜鍔犲瘑涓ENCRYPT()SQL鍑芥暟鐨勬柟娉曠浉鍚屻PASSWORD()鍜ENCRYPT()鍑芥暟鐨勬弿杩板弬瑙12.9.2鑺傦紝鈥滃姞瀵嗗嚱鏁扳銆備粠鐗堟湰4.1 璧凤紝MySQL浣跨敤鏇村己鐨勯壌瀹氭柟娉曪紝鍚屼互鍓嶇殑鐗堟湰鐩告瘮鍙互鍦ㄨ繛鎺ヨ繃绋嬩腑鎻愪緵鏇村ソ鐨勫瘑鐮佷繚鎶ゃ傚嵆浣TCP/IP鍖呰鎴彇鎴mysql鏁版嵁搴撹鎹曡幏涔熷緢瀹夊叏銆(鍦ㄥ墠闈㈢殑鐗堟湰涓紝鍗充娇瀵嗙爜浠ュ姞瀵嗗舰寮忎繚瀛樺埌user琛ㄤ腑锛屼粛鍙互閫氳繃鍔犲瘑瀵嗙爜鍊兼潵杩炴帴MySQL鏈嶅姟鍣級銆
褰撳畨瑁MySQL鏃讹紝鎺堟潈琛ㄨ杞芥椂鏈変竴绯诲垪鍒濅娇璐︽埛銆傝繖浜涜处鎴风殑鍚嶇О鍜岃闂潈闄愯2.9.3鑺傦紝鈥滀娇鍒濆MySQL璐︽埛瀹夊叏鈥锛屽叾涓繕璁ㄨ浜嗗浣曟湭杩欎簺璐︽埛璧嬩簣瀵嗙爜銆傚洜姝わ紝浣犱竴鑸簲浣跨敤GRANT鍜REVOKE璇彞鏉ヨ缃佷慨鏀瑰拰绉婚櫎MySQL璐︽埛銆傚弬瑙13.5.1.3鑺傦紝鈥淕RANT鍜孯EVOKE璇硶鈥銆
褰撶敤鍛戒护琛屽鎴风杩炴帴MySQL鏈嶅姟鍣ㄦ椂锛屼綘搴斾负鎯宠浣跨敤鐨勮处鎴锋寚瀹氱敤鎴峰悕鍜屽瘑鐮侊細
shell> mysql --user=monty --password=guess db_name
濡傛灉浣犳兂鐢ㄨ緝鐭殑閫夐」锛屽懡浠ゅ簲涓猴細
shell> mysql -u monty -pguess db_name
-p閫夐」鍜屽悗闈㈢殑瀵嗙爜鍊间箣闂寸粷瀵逛笉鑳芥湁绌烘牸銆傚弬瑙5.7.4鑺傦紝鈥滀笌MySQL鏈嶅姟鍣ㄨ繛鎺モ銆
鍓嶉潰鐨勫懡浠ゅ寘鎷懡浠よ涓殑瀵嗙爜鍊硷紝浼氬緢鍗遍櫓銆傚弬瑙5.8.6鑺傦紝鈥滀娇浣犵殑瀵嗙爜瀹夊叏鈥銆傝鎯抽伩鍏嶏紝鎸囧畾--password鎴-p閫夐」鍚庨潰涓嶈窡浠讳綍瀵嗙爜鍊硷細
shell> mysql --user=monty --password db_name
shell> mysql -u monty -p db_name
鐒跺悗瀹㈡埛绔▼搴忚緭鍑烘彁绀虹骞剁瓑寰呬綘杈撳叆瀵嗙爜銆(鍦ㄨ繖浜涚ず渚嬩腑锛db_name骞朵笉涓哄瘑鐮侊紝鍥犱负鐢ㄧ┖鏍煎皢瀹冨悓鍓嶉潰鐨勫瘑鐮侀」闅旂寮浜嗭級銆
鍦ㄤ竴浜涚郴缁熶腑锛MySQL鐢ㄦ潵鎻愮ず杈撳叆瀵嗙爜鐨勫簱璋冪敤鑷姩灏嗗瘑鐮侀檺鍒跺埌8涓瓧绗︺傝繖鏄郴缁熷簱鐨勯棶棰橈紝鑰屼笉鏄MySQL鐨勯棶棰樸MySQL鏈韩骞朵笉闄愬埗瀵嗙爜鐨勯暱搴︺傝瑙e喅璇ラ棶棰橈紝灏MySQL瀵嗙爜鏀逛负8涓瓧绗﹀拰鏇村皯瀛楃鐨勫硷紝鎴栧皢瀵嗙爜鏀惧叆閫夐」鏂囦欢涓
鍙互鐢ㄤ袱绉嶆柟寮忓垱寤MySQL璐︽埛锛
路 浣跨敤GRANT璇彞
路 鐩存帴鎿嶄綔MySQL鎺堟潈琛
鏈濂界殑鏂规硶鏄娇鐢GRANT璇彞锛屽洜涓鸿繖鏍锋洿绮剧‘锛岄敊璇皯銆備粠MySQL 3.22.11璧锋彁渚涗簡GRANT锛涘叾璇硶瑙13.5.1.3鑺傦紝鈥淕RANT鍜孯EVOKE璇硶鈥銆
鍒涘缓璐︽埛鐨勫叾瀹冩柟娉曟槸浣跨敤MySQL璐︽埛绠$悊鍔熻兘鐨勭涓夋柟绋嬪簭銆phpMyAdmin鍗虫槸涓涓▼搴忋
涓嬮潰鐨勭ず渚嬭鏄庡浣曚娇鐢MySQL瀹㈡埛绔▼搴忔潵璁剧疆鏂扮敤鎴枫傚亣瀹氭寜鐓2.9.3鑺傦紝鈥滀娇鍒濆MySQL璐︽埛瀹夊叏鈥鎻忚堪鐨 榛樿鍊兼潵璁剧疆鏉冮檺銆傝繖璇存槑涓轰簡鏇存敼锛屼綘蹇呴』浠MySQL root鐢ㄦ埛杩炴帴MySQL鏈嶅姟鍣紝骞朵笖root璐︽埛蹇呴』鏈mysql鏁版嵁搴撶殑INSERT鏉冮檺鍜RELOAD绠$悊鏉冮檺銆
棣栧厛锛屼娇鐢MySQL绋嬪簭浠MySQL root鐢ㄦ埛鏉ヨ繛鎺ユ湇鍔″櫒锛
shell> MySQL --user=root MySQL
濡傛灉浣犱负root璐︽埛鎸囧畾浜嗗瘑鐮侊紝杩橀渶瑕佷负璇MySQL鍛戒护鍜屾湰鑺備腑鐨勫叾瀹冨懡浠ゆ彁渚--password鎴-p閫夐」銆
浠root杩炴帴鍒版湇鍔″櫒涓婂悗锛屽彲浠ユ坊鍔犳柊璐︽埛銆備笅闈㈢殑璇彞浣跨敤GRANT鏉ヨ缃洓涓柊璐︽埛锛
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql> GRANT USAGE ON *.* TO 'dummy'@'localhost';
鐢GRANT璇彞鍒涘缓鐨勮处鎴锋湁涓嬮潰鐨勫睘鎬э細
路 鍏朵腑涓や釜璐︽埛鏈夌浉鍚岀殑鐢ㄦ埛鍚monty鍜屽瘑鐮some_pass銆備袱涓处鎴峰潎涓鸿秴绾х敤鎴疯处鎴凤紝鍏锋湁瀹屽叏鐨勬潈闄愬彲浠ュ仛浠讳綍浜嬫儏銆備竴涓处鎴 ('monty'@'localhost')鍙敤浜庝粠鏈満杩炴帴鏃躲傚彟涓涓处鎴('monty'@'%')鍙敤浜庝粠鍏跺畠涓绘満杩炴帴銆傝娉ㄦ剰monty鐨勪袱涓处鎴峰繀椤昏兘浠庝换浣曚富鏈轰互monty杩炴帴銆傛病鏈localhost璐︽埛锛屽綋monty浠庢湰鏈鸿繛鎺ユ椂锛mysql_install_db鍒涘缓鐨localhost鐨勫尶鍚嶇敤鎴疯处鎴峰皢鍗犲厛銆傜粨鏋滄槸锛monty灏嗚瑙嗕负鍖垮悕鐢ㄦ埛銆傚師鍥犳槸鍖垮悕鐢ㄦ埛璐︽埛鐨Host鍒楀兼瘮'monty'@'%'璐︽埛鏇村叿浣擄紝杩欐牱鍦user琛ㄦ帓搴忛『搴忎腑鎺掑湪鍓嶉潰銆(user琛ㄦ帓搴忕殑璁ㄨ鍙傝5.7.5鑺傦紝鈥滆闂帶鍒, 闃舵1锛氳繛鎺ユ牳瀹炩锛銆
路 涓涓处鎴锋湁鐢ㄦ埛鍚admin锛屾病鏈夊瘑鐮併傝璐︽埛鍙敤浜庝粠鏈満杩炴帴銆傛巿浜堜簡RELOAD鍜PROCESS绠$悊鏉冮檺銆傝繖浜涙潈闄愬厑璁admin鐢ㄦ埛鎵цmysqladmin reload銆mysqladmin refresh鍜mysqladmin flush-xxx鍛戒护锛屼互鍙mysqladmin processlist銆傛湭鎺堜簣璁块棶鏁版嵁搴撶殑鏉冮檺銆備綘鍙互閫氳繃GRANT璇彞娣诲姞姝ょ被鏉冮檺銆
路 涓涓处鎴锋湁鐢ㄦ埛鍚dummy锛屾病鏈夊瘑鐮併傝璐︽埛鍙敤浜庝粠鏈満杩炴帴銆傛湭鎺堜簣鏉冮檺銆傞氳繃GRANT璇彞涓殑USAGE鏉冮檺锛屼綘鍙互鍒涘缓璐︽埛鑰屼笉鎺堜簣浠讳綍鏉冮檺銆傚畠鍙互灏嗘墍鏈夊叏灞鏉冮檺璁句负'N'銆傚亣瀹氫綘灏嗗湪浠ュ悗灏嗗叿浣撴潈闄愭巿浜堣璐︽埛銆
闄や簡GRANT锛屼綘鍙互鐩存帴鐢INSERT璇彞鍒涘缓鐩稿悓鐨勮处鎴凤紝鐒跺悗浣跨敤FLUSH PRIVILEGES鍛婅瘔鏈嶅姟鍣ㄩ噸杞芥巿鏉冭〃锛
shell> mysql --user=root mysql
mysql> INSERT INTO user
-> VALUES('localhost','monty',PASSWORD('some_pass'),
-> 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
mysql> INSERT INTO user
-> VALUES('%','monty',PASSWORD('some_pass'),
-> 'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
mysql> INSERT INTO user SET Host='localhost',User='admin',
-> Reload_priv='Y', Process_priv='Y';
mysql> INSERT INTO user (Host,User,Password)
-> VALUES('localhost','dummy','');
mysql> FLUSH PRIVILEGES;
褰撲綘鐢INSERT鍒涘缓璐︽埛鏃朵娇鐢FLUSH PRIVILEGES鐨勫師鍥犳槸鍛婅瘔鏈嶅姟鍣ㄩ噸璇绘巿鏉冭〃銆傚惁鍒欙紝鍙湁閲嶅惎鏈嶅姟鍣ㄥ悗鏇存敼鏂逛細琚敞鎰忓埌銆備娇鐢 GRANT锛屽垯涓嶉渶瑕佷娇鐢FLUSH PRIVILEGES銆
鐢INSERT浣跨敤PASSWORD()鍑芥暟鏄负浜嗗姞瀵嗗瘑鐮併GRANT璇彞涓轰綘鍔犲瘑瀵嗙爜锛屽洜姝や笉闇瑕PASSWORD()銆
'Y'鍊煎惎鐢ㄨ处鎴锋潈闄愩傚浜admin璐︽埛锛岃繕鍙互浣跨敤鏇村姞鍙鐨INSERT鎵╁厖鐨勮娉曪紙浣跨敤SET锛夈
鍦ㄤ负dummy璐︽埛鐨INSERT璇彞涓紝鍙湁user琛ㄤ腑鐨Host銆User鍜Password鍒楄褰曚负鎸囧畾鐨勫笺傛病鏈変竴涓潈闄愬垪涓烘樉寮忚缃紝鍥犳MySQL灏嗗畠浠潎鎸囧畾涓 榛樿鍊'N'銆傝繖鏍风瓑鍚屼簬GRANT USAGE鐨勬搷浣溿
璇锋敞鎰忚璁剧疆瓒呯骇鐢ㄦ埛璐︽埛锛屽彧闇瑕佸垱寤轰竴涓潈闄愬垪璁剧疆涓'Y'鐨user琛ㄦ潯鐩user琛ㄦ潈闄愪负鍏ㄥ眬鏉冮檺锛屽洜姝ゅ叾瀹 鎺堟潈琛ㄤ笉鍐嶉渶瑕佹潯鐩
涓嬮潰鐨勪緥瀛愬垱寤3涓处鎴凤紝鍏佽瀹冧滑璁块棶涓撶敤鏁版嵁搴撱傛瘡涓处鎴风殑鐢ㄦ埛鍚嶄负custom锛屽瘑鐮佷负obscure銆
瑕佹兂鐢GRANT鍒涘缓璐︽埛锛屼娇鐢ㄤ笅闈㈢殑璇彞锛
shell> MySQL --user=root MySQL
shell> mysql --user=root mysql
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
-> ON bankaccount.*
-> TO 'custom'@'localhost'
-> IDENTIFIED BY 'obscure';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
-> ON expenses.*
-> TO 'custom'@'whitehouse.gov'
-> IDENTIFIED BY 'obscure';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
-> ON customer.*
-> TO 'custom'@'server.domain'
-> IDENTIFIED BY 'obscure';
杩3涓处鎴峰彲浠ョ敤浜庯細
路 绗1涓处鎴峰彲浠ヨ闂bankaccount鏁版嵁搴擄紝浣嗗彧鑳戒粠鏈満璁块棶銆
路 绗2涓处鎴峰彲浠ヨ闂expenses鏁版嵁搴擄紝浣嗗彧鑳戒粠涓绘満whitehouse.gov璁块棶銆
路 绗3涓处鎴峰彲浠ヨ闂customer鏁版嵁搴擄紝浣嗗彧鑳戒粠涓绘満server.domain璁块棶銆
瑕佹兂涓嶇敤GRANT璁剧疆custom璐︽埛锛屼娇鐢INSERT璇彞鐩存帴淇敼 鎺堟潈琛細
shell> mysql --user=root mysql
mysql> INSERT INTO user (Host,User,Password)
-> VALUES('localhost','custom',PASSWORD('obscure'));
mysql> INSERT INTO user (Host,User,Password)
-> VALUES('whitehouse.gov','custom',PASSWORD('obscure'));
mysql> INSERT INTO user (Host,User,Password)
-> VALUES('server.domain','custom',PASSWORD('obscure'));
mysql> INSERT INTO db
-> (Host,Db,User,Select_priv,Insert_priv,
-> Update_priv,Delete_priv,Create_priv,Drop_priv)
-> VALUES('localhost','bankaccount','custom',
-> 'Y','Y','Y','Y','Y','Y');
mysql> INSERT INTO db
-> (Host,Db,User,Select_priv,Insert_priv,
-> Update_priv,Delete_priv,Create_priv,Drop_priv)
-> VALUES('whitehouse.gov','expenses','custom',
-> 'Y','Y','Y','Y','Y','Y');
mysql> INSERT INTO db
-> (Host,Db,User,Select_priv,Insert_priv,
-> Update_priv,Delete_priv,Create_priv,Drop_priv)
-> VALUES('server.domain','customer','custom',
-> 'Y','Y','Y','Y','Y','Y');
mysql> FLUSH PRIVILEGES;
鍓3涓INSERT璇彞鍦user琛ㄤ腑鍔犲叆鏉$洰锛屽厑璁哥敤鎴custom浠庡悇绉嶄富鏈虹敤缁欏畾鐨勫瘑鐮佽繘琛岃繛鎺ワ紝浣嗕笉鎺堜簣鍏ㄥ眬鏉冮檺(鎵鏈夋潈闄愯缃负 榛樿鍊'N')銆傚悗闈3涓INSERT璇彞鍦user琛ㄤ腑鍔犲叆鏉$洰锛屼负custom鎺堜簣bankaccount銆expenses鍜customer鏁版嵁搴撴潈闄愶紝浣嗗彧鑳戒粠鍚堥傜殑涓绘満璁块棶銆閫氬父鑻ョ洿鎺ヤ慨鏀 鎺堟潈琛紝鍒欏簲鍛婅瘔鏈嶅姟鍣ㄧ敤FLUSH PRIVILEGES閲嶈浇鎺堟潈琛紝浣挎潈闄愭洿鏀圭敓鏁堛
濡傛灉浣犳兂瑕佽鏌愪釜鐢ㄦ埛浠庣粰瀹氬煙鐨勬墍鏈夋満鍣ㄨ闂(渚嬪锛mydomain.com)锛屼綘鍙互鍦ㄨ处鎴峰悕鐨勪富鏈洪儴鍒嗕娇鐢ㄥ惈鈥%鈥欓氶厤绗︾殑GRANT璇彞锛
mysql> GRANT ...
-> ON *.*
-> TO 'myname'@'%.mydomain.com'
-> IDENTIFIED BY 'mypass';
瑕佹兂閫氳繃鐩存帴淇敼鎺堟潈琛ㄦ潵瀹炵幇锛
mysql> INSERT INTO user (Host,User,Password,...)
-> VALUES('%.mydomain.com','myname',PASSWORD('mypass'),...);
mysql> FLUSH PRIVILEGES;
闄愬埗MySQL鏈嶅姟鍣ㄨ祫婧愪娇鐢ㄧ殑涓涓柟娉曟槸灏max_user_connections绯荤粺鍙橀噺璁剧疆涓洪潪闆跺笺備絾鏄紝璇ユ柟娉曚弗鏍奸檺浜庡叏灞锛屼笉鍏佽绠$悊鍏蜂綋璐︽埛銆傚苟涓旓紝瀹冨彧闄愬埗浣跨敤鍗曚竴璐︽埛鍚屾椂杩炴帴鐨勬暟閲忥紝鑰屼笉鏄鎴风杩炴帴鍚庣殑鎿嶄綔銆傝澶MySQL绠$悊鍛樺涓ょ绫诲瀷鐨勬帶鍒跺潎鎰熷叴瓒o紝鐗瑰埆鏄Internet鏈嶅姟鎻愪緵鑰呫
鍦MySQL 5.1涓,浣犲彲浠ヤ负鍏蜂綋璐︽埛闄愬埗涓嬮潰鐨勬湇鍔″櫒璧勬簮锛
路 璐︽埛姣忓皬鏃跺彲浠ュ彂鍑虹殑鏌ヨ鏁
路 璐︽埛姣忓皬鏃跺彲浠ュ彂鍑虹殑鏇存柊鏁
路 璐︽埛姣忓皬鏃跺彲浠ヨ繛鎺ユ湇鍔″櫒鐨勬鏁
瀹㈡埛绔彲浠ユ墽琛岀殑璇彞鏍规嵁鏌ヨ闄愬埗鏉ヨ鏁般傚彧鏈変慨鏀规暟鎹簱鎴栬〃鐨勮鍙ユ牴鎹洿鏂伴檺鍒舵潵璁版暟銆
杩樺彲浠ラ檺鍒舵瘡涓处鎴风殑鍚屾椂杩炴帴鏈嶅姟鍣ㄧ殑杩炴帴鏁般
鏈枃涓殑璐︽埛涓user琛ㄤ腑鐨勫崟涓褰曘傛牴鎹User鍜Host鍒楀煎敮涓璇嗗埆姣忎釜璐︽埛銆
鍋氫负浣跨敤璇ョ壒鎬х殑鍏堝喅鏉′欢锛mysql鏁版嵁搴撶殑user琛ㄥ繀椤诲寘鍚祫婧愮浉鍏崇殑鍒椼傝祫婧愰檺鍒朵繚瀛樺湪max_questions銆max_updates銆max_connections鍜max_user_connections鍒楀唴銆傚鏋user琛ㄦ病鏈夎繖浜涘垪锛屽繀椤诲瀹冭繘琛屽崌绾э紱鍙傝2.10.2鑺傦紝鈥滃崌绾ф巿鏉冭〃鈥銆
瑕佹兂鐢GRANT璇彞璁剧疆璧勬簮闄愬埗锛屼娇WITH瀛愬彞鏉ュ懡鍚嶆瘡涓闄愬埗鐨勮祫婧愬拰鏍规嵁姣忓皬鏃惰鏁扮殑闄愬埗鍊笺備緥濡傦紝瑕佹兂鍙互闄愬埗鏂瑰紡鍒涘缓鍙互璁块棶customer鏁版嵁搴撶殑鏂拌处鎴凤紝鎵ц璇ヨ鍙ワ細
mysql> GRANT ALL ON customer.* TO 'francis'@'localhost'
-> IDENTIFIED BY 'frank'
-> WITH MAX_QUERIES_PER_HOUR 20
-> MAX_UPDATES_PER_HOUR 10
-> MAX_CONNECTIONS_PER_HOUR 5
-> MAX_USER_CONNECTIONS 2;
闄愬埗绫诲瀷涓嶉渶瑕佸叏閮ㄥ湪WITH瀛愬彞涓懡鍚嶏紝浣嗗凡缁忓懡鍚嶇殑鍙互鎸変换浣曢『搴忋傛瘡涓瘡灏忔椂闄愬埗鍊煎潎搴斾负鏁存暟锛屼唬琛ㄦ瘡灏忔椂鐨勮鏁般傚鏋GRANT璇彞娌℃湁WITH瀛愬彞锛屽垯姣忎釜闄愬埗鍊艰缃负 榛樿鍊奸浂(鍗虫病鏈夐檺鍒)銆傚浜MAX_USER_CONNECTIONS锛岄檺鍒朵负鏁存暟锛岃〃绀鸿处鎴蜂竴娆″彲浠ュ悓鏃惰繛鎺ョ殑鏈澶ц繛鎺ユ暟銆傚鏋滈檺鍒惰缃负 榛樿鍊奸浂锛屽垯鏍规嵁MAX_USER_CONNECTIONS绯荤粺鍙橀噺纭畾璇ヨ处鎴峰彲浠ュ悓鏃惰繛鎺ョ殑鏁伴噺銆
瑕佹兂璁剧疆鎴栨洿鏀瑰凡鏈夎处鎴风殑闄愬埗锛屽湪鍏ㄥ眬绾у埆浣跨敤GRANT USAGE璇彞(鍦*.*)銆備笅闈㈢殑璇彞鍙互灏francis鐨勬煡璇㈤檺鍒舵洿鏀逛负100锛
mysql> GRANT USAGE ON *.* TO 'francis'@'localhost'
-> WITH MAX_QUERIES_PER_HOUR 100;
璇ヨ鍙ユ病鏈夋敼鍙樿处鎴风殑宸叉湁鏉冮檺锛屽彧淇敼浜嗘寚瀹氱殑闄愬埗鍊笺
瑕佹兂鍙栨秷宸叉湁闄愬埗锛屽皢璇ュ艰缃负闆躲備緥濡傦紝瑕佹兂鍙栨秷francis姣忓皬鏃跺彲浠ヨ繛鎺ョ殑娆℃暟鐨勯檺鍒讹紝浣跨敤璇ヨ鍙ワ細
mysql> GRANT USAGE ON *.* TO 'francis'@'localhost'
-> WITH MAX_CONNECTIONS_PER_HOUR 0;
褰撹处鎴蜂娇鐢ㄨ祫婧愭椂濡傛灉鏈夐潪闆堕檺鍒讹紝鍒欏璧勬簮浣跨敤杩涜璁版暟銆
鏈嶅姟鍣ㄨ繍琛屾椂锛屽畠缁熻姣忎釜璐︽埛浣跨敤璧勬簮鐨勬鏁般傚鏋滆处鎴峰湪鏈鍚庝竴涓皬鏃剁殑杩炴帴娆℃暟杈惧埌闄愬埗锛岃璐︽埛鐨勮繘涓姝ョ殑杩炴帴琚嫆缁濄傜被浼煎湴锛屽鏋滆处鎴疯揪鍒版煡璇㈡垨鏇存柊娆℃暟鐨勯檺鍒讹紝杩涗竴姝ョ殑鏌ヨ鎴栨洿鏂拌鎷掔粷銆傚湪杩欑鎯呭喌涓嬶紝浼氱粰鍑虹浉鍏抽敊璇秷鎭
鏍规嵁姣忎釜璐︽埛杩涜璧勬簮璁$畻锛岃屼笉鏄牴鎹瘡涓鎴风銆備緥濡傦紝濡傛灉浣犵殑璐︽埛鐨勬煡璇㈤檺鍒朵负50,浣犱笉鑳介氳繃涓や釜瀹㈡埛绔悓鏃惰繛鎺ユ湇鍔″櫒灏嗛檺鍒跺鍔犲埌100銆備袱涓繛鎺ョ殑鏌ヨ琚绠楀埌涓璧枫
鍙互涓烘墍鏈夎处鎴蜂粠鍏ㄥ眬閲嶈褰撳墠鐨勬瘡灏忔椂璧勬簮浣跨敤璁版暟锛屾垨鍗曠嫭閲嶈缁欏畾鐨勮处鎴凤細
路 瑕佹兂灏嗘墍鏈夎处鎴峰綋鍓嶇殑璁版暟閲嶈涓洪浂锛屽彲浠ユ墽琛FLUSH USER_RESOURCES璇彞銆傝繕鍙互閫氳繃閲嶈浇鎺堟潈琛ㄦ潵閲嶈璁版暟(渚嬪锛屼娇鐢FLUSH PRIVILEGES璇彞鎴mysqladmin reload鍛戒护)銆
路 灏嗗叿浣撹处鎴风殑闄愬埗閲嶆柊鎺堜簣浠讳綍鍊硷紝鍙互灏嗗畠璁剧疆涓洪浂銆傝鎯冲疄鐜帮紝鎸夌収鍓嶉潰鎵杩颁娇鐢GRANT USAGE锛屽苟灏嗛檺鍒跺兼寚瀹氫负璇ヨ处鎴峰綋鍓嶇殑闄愬埗鍊笺
璁℃暟鍣ㄩ噸璁句笉褰卞搷MAX_USER_CONNECTIONS闄愬埗銆
褰撴湇鍔″櫒鍚姩鏃舵墍鏈夎鏁颁粠闆跺紑濮嬨
shell> mysqladmin -u user_name -h host_name password "newpwd"
璇ュ懡浠ら噸璁惧瘑鐮佺殑璐︽埛涓user琛ㄥ唴鍖归厤User鍒楃殑user_name鍜Host鍒浣犲彂璧疯繛鎺ョ殑瀹㈡埛绔殑璁板綍銆
涓鸿处鎴疯祴浜堝瘑鐮佺殑鍙︿竴绉嶆柟娉曟槸鎵цSET PASSWORD璇彞锛
mysql> SET PASSWORD FOR 'jeffrey'@'%' = PASSWORD('biscuit');
鍙湁root绛夊彲浠ユ洿鏂mysql鏁版嵁搴撶殑鐢ㄦ埛鍙互鏇存敼鍏跺畠鐢ㄦ埛鐨勫瘑鐮併傚鏋滀綘娌℃湁浠ュ尶鍚嶇敤鎴疯繛鎺ワ紝鐪佺暐FOR瀛愬彞渚垮彲浠ユ洿鏀硅嚜宸辩殑瀵嗙爜锛
mysql> SET PASSWORD = PASSWORD('biscuit');
浣犺繕鍙互鍦ㄥ叏灞绾у埆浣跨敤GRANT USAGE璇彞(鍦*.*)鏉ユ寚瀹氭煇涓处鎴风殑瀵嗙爜鑰屼笉褰卞搷璐︽埛褰撳墠鐨勬潈闄愶細
mysql> GRANT USAGE ON *.* TO 'jeffrey'@'%' IDENTIFIED BY 'biscuit';
涓鑸儏鍐典笅鏈濂戒娇鐢ㄤ笂杩版柟娉曟潵鎸囧畾瀵嗙爜锛屼綘杩樺彲浠ョ洿鎺ヤ慨鏀user琛細
路 瑕佹兂鍦ㄥ垱寤烘柊璐︽埛鏃跺缓绔嬪瘑鐮侊紝鍦Password鍒楁彁渚涗竴涓硷細
路 shell> mysql -u root mysql
路 mysql> INSERT INTO user (Host,User,Password)
路 -> VALUES('%','jeffrey',PASSWORD('biscuit'));
路 mysql> FLUSH PRIVILEGES;
路
路 瑕佹兂鏇存敼宸叉湁璐︽埛鐨勫瘑鐮侊紝浣跨敤UPDATE鏉ヨ缃Password鍒楀硷細
路 shell> mysql -u root mysql
路 mysql> UPDATE user SET Password = PASSWORD('bagel')
路 -> WHERE Host = '%' AND User = 'francis';
路 mysql> FLUSH PRIVILEGES;
褰撲綘浣跨敤SET PASSWORD銆INSERT鎴UPDATE鎸囧畾璐︽埛鐨勫瘑鐮佹椂锛屽繀椤荤敤PASSWORD()鍑芥暟瀵瑰畠杩涜鍔犲瘑銆(鍞竴鐨勭壒渚嬫槸濡傛灉瀵嗙爜涓虹┖锛屼綘涓嶉渶瑕佷娇鐢PASSWORD())銆傞渶瑕佷娇鐢PASSWORD()鏄洜涓user琛ㄤ互鍔犲瘑鏂瑰紡淇濆瓨瀵嗙爜锛岃屼笉鏄槑鏂囥傚鏋滀綘蹇樿浜嗭紝浣犲彲鑳戒細璞¤繖鏍疯缃瘑鐮侊細
shell> mysql -u root mysql
mysql> INSERT INTO user (Host,User,Password)
-> VALUES('%','jeffrey','biscuit');
mysql> FLUSH PRIVILEGES;
缁撴灉鏄瘑鐮'biscuit'淇濆瓨鍒user琛ㄥ悗娌℃湁鍔犲瘑銆傚綋jeffrey浣跨敤璇ュ瘑鐮佽繛鎺ユ湇鍔″櫒鏃讹紝鍊艰鍔犲瘑骞跺悓淇濆瓨鍦user琛ㄤ腑鐨勮繘琛屾瘮杈冦備絾鏄紝淇濆瓨鐨勫间负瀛楃涓'biscuit'锛屽洜姝ゆ瘮杈冨皢澶辫触锛屾湇鍔″櫒鎷掔粷杩炴帴锛
shell> mysql -u jeffrey -pbiscuit test
Access denied
濡傛灉浣犱娇鐢GRANT ... IDENTIFIED BY璇彞鎴mysqladmin password鍛戒护璁剧疆瀵嗙爜锛屽畠浠潎浼氬姞瀵嗗瘑鐮併傚湪杩欑鎯呭喌涓嬶紝涓嶉渶瑕佷娇鐢 PASSWORD()鍑芥暟銆
娉閲婏細PASSWORD()鍔犲瘑涓嶅悓浜Unix瀵嗙爜鍔犲瘑銆傚弬瑙5.8.1鑺傦紝鈥淢ySQL鐢ㄦ埛鍚嶅拰瀵嗙爜鈥銆
鍦ㄧ鐞嗙骇鍒紝浣犲喅涓嶈兘灏mysql.user琛ㄧ殑璁块棶鏉冮檺鎺堜簣浠讳綍闈炵鐞嗚处鎴枫
褰撲綘杩愯瀹㈡埛绔▼搴忚繛鎺MySQL鏈嶅姟鍣ㄦ椂锛屼互涓绉嶆毚闇茬殑鍙鍏朵粬鐢ㄦ埛鍙戠幇鐨勬柟寮忔寚瀹氫綘鐨勫瘑鐮佹槸涓嶅Ε褰撶殑銆傚綋浣犺繍琛屽鎴风绋嬪簭鏃讹紝浣犲彲浠ヤ娇鐢ㄤ笅鍒楁柟娉曟寚瀹氫綘鐨勫瘑鐮侊紝杩樻湁姣忎釜鏂规硶鐨勯闄╄瘎浼帮細
路 浣跨敤涓涓湪鍛戒护琛屼笂-pyour_pass鎴--password=your_pass鐨勯夐」銆備緥濡傦細
路 shell> mysql -u francis -pfrank db_name
杩欏緢鏂逛究浣嗘槸涓嶅畨鍏紝鍥犱负浣犵殑瀵嗙爜瀵圭郴缁熺姸鎬佺▼搴(渚嬪ps)鍙樺緱鍙锛屽畠鍙互琚叾浠栫殑鐢ㄦ埛璋冪敤鏉ユ樉绀哄懡浠よ銆備竴鑸MySQL瀹㈡埛鍦ㄤ粬浠殑鍒濆鍖栭『搴忔湡闂寸敤闆惰鐩栧懡浠よ鍙傛暟锛屼絾鏄粛鐒舵湁涓涓煭鏆傞棿闅旀椂闂村唴鍙傛暟鍊煎彲瑙佺殑銆
路 浣跨敤涓涓-p鎴--password閫夐」(娌℃湁鎸囧畾瀵嗙爜)銆傚湪杩欑鎯呭喌涓嬶紝瀹㈡埛绔▼搴忚姹傛潵鑷粓绔殑瀵嗙爜锛
路 shell> mysql -u francis -p db_name
路 Enter password: ********
鈥*鈥瀛楃鎸囩ず杈撳叆瀵嗙爜鐨勫湴鏂广傝緭鍏ュ瘑鐮佹椂瀵嗙爜鐪嬩笉瑙併
鍥犱负瀹冨鍏朵粬鐢ㄦ埛涓嶅彲瑙侊紝涓庡湪鍛戒护琛屼笂鎸囧畾瀹冪浉姣旓紝杩欐牱杩涘叆浣犵殑瀵嗙爜鏇村畨鍏ㄣ傜劧鑰岋紝杩欎釜杈撳叆涓涓瘑鐮佺殑鏂规硶浠呬粎涓轰綘浜や簰寮忚繍琛岀▼搴忔槸鍚堥傜殑銆傚鏋滀綘鎯宠浠庨潪浜や簰寮忚繍琛岀殑涓涓剼鏈皟鐢ㄤ竴涓鎴风锛屽氨娌℃湁浠庣粓绔緭鍏ュ叆瀵嗙爜鐨勬満浼氥傚湪鏌愪簺绯荤粺涓紝浣犵敋鑷充細鍙戠幇鑴氭湰鐨勭涓琛岃锛堥敊璇湴锛夎骞惰В閲婁负浣犵殑瀵嗙爜锛
路 鍦ㄤ竴涓厤缃枃浠朵腑瀛樺偍浣犵殑瀵嗙爜銆備緥濡傦紝鍦Unix涓紝浣犲彲鍦ㄤ富鐩綍鐨鈥.my.cnf鈥鏂囦欢涓殑[client]鑺傚垪鍑轰綘鐨勫瘑鐮侊細
路 [client]
路 password=your_pass
濡傛灉浣犲湪鈥.my.cnf鈥閲岄潰瀛樺偍瀵嗙爜锛岄櫎浜嗕綘鏈汉鍏跺畠浜轰笉鑳借闂鏂囦欢銆備繚璇佹枃浠剁殑璁块棶妯″紡鏄400鎴600銆渚嬪锛
shell> chmod 600 .my.cnf
鍏充簬閫夐」鏂囦欢鐨勮缁嗚璁哄弬瑙4.3.2鑺傦紝鈥滀娇鐢ㄩ夐」鏂囦欢鈥銆
路 浣犲彲鍦MYSQL_PWD鐜鍙橀噺涓瓨鍌ㄥ瘑鐮併備絾鏄繖绉嶆寚瀹MySQL瀵嗙爜鐨勬柟娉曟槸鏋佷笉瀹夊叏鐨勶紝涓嶅簲璇ヤ娇鐢ㄣps鐨勬煇浜涚増鏈寘鎷樉绀鸿繍琛岃繘绋嬬殑鐜鐨勯夐」锛涘鏋滀綘璁惧畾MYSQL_PWD锛屼綘鐨勫瘑鐮佸皢琚繍琛ps鐨勬墍鏈変汉鐪嬭锛岀敋鑷冲湪娌℃湁杩欐牱涓涓増鏈殑ps鐨勭郴缁熶笂锛屾病鏈夊叾瀹冩柟娉曡瀵熷埌杩涚▼鐜鐨勫亣璁炬槸涓嶆槑鏅虹殑銆傚弬瑙闄勫綍F锛鐜鍙橀噺銆
鎬讳箣锛屾渶瀹夊叏鐨勬柟娉曟槸璁╁鎴风绋嬪簭鎻愮ず杈撳叆瀵嗙爜鎴栧湪閫傚綋淇濇姢鐨勯夐」鏂囦欢涓寚瀹氬瘑鐮併
MySQL鐨勬爣鍑嗛厤缃惧悜浜庡敖鍙兘蹇紝鍥犳榛樿鎯呭喌涓嶄娇鐢ㄥ姞瀵嗚繛鎺ャ備娇鐢ㄨ鍗忚浼氫娇瀹㈡埛绔/鏈嶅姟鍣ㄥ崗璁參寰楀銆傚鏁版嵁杩涜鍔犲瘑闈炲父鑰CPU锛岄渶瑕佽绠楁満澶氬仛璁稿宸ヤ綔锛屼細寤惰繜MySQL鐨勫叾瀹冧换鍔°傚浜庨渶瑕侀氳繃鍔犲瘑杩炴帴鎻愪緵瀹夊叏鐨勫簲鐢ㄧ▼搴忥紝鍙互淇濊瘉棰濆鐨勮绠椼
MySQL鍏佽鍦ㄨ繛鎺ュ墠鍚敤鍔犲瘑銆備綘鍙互鏍规嵁鍏蜂綋搴旂敤绋嬪簭鐨勯渶姹傞夋嫨鏅氭湭鍔犲瘑杩炴帴鎴栧畨鍏ㄥ姞瀵SSL杩炴帴銆
榛樿鎯呭喌涓嬶紝MySQL鍦ㄥ鎴风鍜屾湇鍔″櫒涔嬮棿浣跨敤鏈姞瀵嗙殑杩炴帴銆傝繖璇存槑鍙互璁块棶缃戠粶鐨勯儴鍒嗕汉鍙互鐪嬪埌浣犵殑閫氫俊锛屽苟鐪嬪埌鍙戦佸拰鎺ユ敹鐨勬暟鎹備粬浠敋鑷冲彲浠ユ洿鏀瑰湪瀹㈡埛绔拰鏈嶅姟鍣ㄤ箣闂翠紶閫掔殑鏁版嵁銆傝鎯虫彁楂樺畨鍏ㄦэ紝褰撹皟鐢ㄥ鎴风绋嬪簭鏃讹紝浣犲彲浠ラ氳繃--compress閫夐」鍘嬬缉瀹㈡埛绔/鏈嶅姟鍣ㄤ箣闂寸殑閫氫俊銆備絾鏄紝杩欐牱骞朵笉鑳介樆鎸′綇椤藉浐鐨勬敾鍑昏呫
褰撲綘闇瑕佷互瀹夊叏鏂瑰紡鍦ㄧ綉缁滀腑浼犻掍俊鎭椂锛屾湭鍔犲瘑鐨勮繛鎺ユ槸涓嶅彲鎺ュ彈鐨勩傚姞瀵嗘槸浣夸换浣曟暟鎹笉鍙鐨勬柟娉曘備簨瀹炰笂锛屼粖澶╃殑璁稿鎯緥闇瑕佸姞瀵嗙畻娉曟彁渚涙洿鍔犲畨鍏ㄧ殑瑕佺礌銆傚畠浠簲鑳芥姷鎶楀悇绉嶅凡鐭ョ殑鏀诲嚮锛屼緥濡傛洿鏀瑰姞瀵嗘秷鎭殑椤哄簭鎴栦袱娆¢噸鏀炬暟鎹
SSL鏄竴绉嶄娇鐢ㄤ笉鍚岀殑鍔犲瘑绠楁硶纭繚浠庡叕鐢ㄧ綉鎺ユ敹鍒扮殑鏁版嵁鏄彲淇$殑鍗忚銆傚畠鍏锋湁妫娴嬫暟鎹洿鏀广佷涪澶辨垨閲嶆斁鐨勬満鍒躲SSL杩樺寘鎷娇鐢 X509鏍囧噯鎻愪緵韬唤璁よ瘉鐨勭畻娉曘
浣跨敤X509锛屽彲浠ヨ瘑鍒Internet涓婄殑鏌愪簺浜恒傞氬父鐢ㄤ簬鐢靛瓙鍟嗗姟搴旂敤绋嬪簭涓傛寜鐓у熀鏈蹇碉紝搴旀湁鏌愮绉颁箣涓衡璁よ瘉鏈烘瀯鈥(鎴CA)鐨勬満鏋勶紝鍙互鍚戣姹傝呭垎鍙戠數瀛愯瘉涔︺傝瘉涔︿緷璧栭潪瀵圭О鍔犲瘑绠楁硶锛屾湁涓や釜鍔犲瘑瀵嗛挜(鍏叡瀵嗛挜鍜岀浜哄瘑閽)銆傝璇佹寔鏈夎呭彲浠ュ悜鍏跺畠鏂瑰嚭绀鸿瘉涔︽潵璇佹槑韬唤銆傝瘉涔﹀寘鎷寔鏈夎呯殑鍏叡瀵嗛挜銆傚彧鑳戒娇鐢ㄥ搴旂殑绉佷汉瀵嗛挜瀵瑰惈璇ュ叕鍏卞瘑閽ョ殑鍔犲瘑鏁版嵁杩涜瑙e瘑锛岀浜哄瘑閽ョ敱璇佷功鎸佹湁鑰呮嫢鏈夈
濡傛灉浣犻渶瑕佸叧浜SSL銆X509銆佹垨鍔犲瘑鐨勮缁嗕俊鎭紝浣跨敤Internet鎼滅储寮曟搸鏉ユ悳绱綘鎰熷叴瓒g殑鍏抽敭瀛椼
瑕佹兂鍦MySQL鏈嶅姟鍣ㄥ拰瀹㈡埛绔▼搴忎箣闂翠娇鐢SSL杩炴帴锛岀郴缁熷繀椤昏兘澶熸敮鎸OpenSSL銆傚鏋滅敤鏀寔鍐呭祵寮yaSSL鐨MySQL鐗堟湰锛屼笉瑕佽璇ヨ妭锛屼絾搴旈槄璇5.8.7.3鑺傦紝鈥滀娇鐢▂aSSL鈥銆
瑕佹兂鑾峰緱瀹夊叏鐨MySQL杩炴帴锛屽繀椤伙細
1. 瀹夎OpenSSL搴撱傛垜浠凡缁忔祴璇曚簡甯OpenSSL 0.9.6鐨MySQL銆傚鏋滀綘闇瑕OpenSSL锛岃璁块棶http://www.openssl.org銆
2. 閰嶇疆MySQL锛岀敤--with-vio鍜--with-openssl閫夐」杩愯configure鑴氭湰銆
3. 纭繚鍗囩骇浜嗘巿鏉冭〃锛屼娇mysql.user琛ㄥ唴鍖呭惈SSL鐩稿叧鍒椼傚鏋 鎺堟潈琛ㄦ槸浠MySQL 4.0.0涔嬪墠鐨勭増鏈崌绾э紝杩欏緢閲嶈銆傚崌绾ц繃绋嬭2.10.2鑺傦紝鈥滃崌绾ф巿鏉冭〃鈥銆
4. 瑕佹兂妫鏌ユ槸鍚﹁繍琛岀殑mysqld鏈嶅姟鍣鏀寔OpenSSL锛屽簲妫鏌have_openssl绯荤粺鍙橀噺鐨勫硷細
5. mysql> SHOW VARIABLES LIKE 'have_openssl';
6. +---------------+-------+
7. | Variable_name | Value |
8. +---------------+-------+
9. | have_openssl | YES |
10. +---------------+-------+
濡傛灉鍊间负YES锛屾湇鍔″櫒鏀寔OpenSSL杩炴帴銆
浣跨敤MySQL鐨勫唴宓屽紡yaSSL鏀寔锛屽彲浠ュ緢瀹规槗鍦颁娇鐢ㄥ畨鍏ㄨ繛鎺ャ備笉闇瑕佸畨瑁OpenSSL鍜屾墽琛5.8.7.2鑺傦紝鈥滈渶姹(OpenSSL)鈥涓殑姝ラ銆傚苟涓旓紝MySQL鍜yaSSL浣跨敤鐩稿悓鐨勮鍙ā鍨嬨
褰撳墠锛屽湪浠ヤ笅骞冲彴涓婃敮鎸yaSSL锛
路 Linux/x86-64 Red Hat Enterprise 3.0
路 Linux RHAS21 Itanium-2锛屽甫gcc锛岄潤鎬侀摼鎺
路 Linux Itanium-2锛屽甫gcc
路 Windows
褰撲粠婧愮爜鏋勫缓MySQL鏃跺鏋滀綘鎯宠鍚敤yaSSL锛屽簲杩欐牱閰嶇疆MySQL锛
./configure --with-yassl=yes
瑕佹兂鍚姩MySQL鏈嶅姟鍣ㄦ敮鎸yaSSL锛屼娇鐢ㄦ敮鎸OpenSSL鐨勭浉鍚岀殑閫夐」锛屽苟璇嗗埆寤虹珛瀹夊叏杩炴帴闇瑕佺殑璇佷功锛
shell> mysqld --ssl-ca=cacert.pem \
--ssl-cert=server-cert.pem \
--ssl-key=server-key.pem
路 --ssl-ca璇嗗埆璁よ瘉鏈烘瀯璇佷功銆
路 --ssl-cert璇嗗埆鏈嶅姟鍣ㄨ瘉涔︺
路 --ssl-key璇嗗埆瀹㈡埛璇佷功銆
瑕佹兂鐢yaSSL鏀寔寤虹珛涓MySQL鏈嶅姟鍣ㄧ殑瀹夊叏杩炴帴锛屽簲杩欐牱鍚姩瀹㈡埛绔細
shell> mysql --ssl-ca=cacert.pem \
--ssl-cert=server-cert.pem \
--ssl-key=server-key.pem
鎹㈠彞璇濊锛岄夐」涓庢湇鍔″櫒鐨勭浉鍚岋紝骞朵笖璁よ瘉鏈烘瀯璇佷功蹇呴』鐩稿悓銆
瑕佹兂浠庡簲鐢ㄧ▼搴忓缓绔嬪畨鍏ㄨ繛鎺ワ紝璋冪敤mysql_real_connect()涔嬪墠锛屽簲浣跨敤mysql_ssl_set()API鍑芥暟鏉ヨ缃浉搴旇璇侀夐」銆傚弬瑙25.2.3.64鑺傦紝鈥渕ysql_ssl_set()鈥銆
DIR=`pwd`/openssl
PRIV=$DIR/private
mkdir $DIR $PRIV $DIR/newcerts
cp /usr/share/ssl/openssl.cnf $DIR
replace ./demoCA $DIR -- $DIR/openssl.cnf
# Create necessary files: $database, $serial and $new_certs_dir
# directory (optional)
touch $DIR/index.txt
echo "01" > $DIR/serial
#
# Generation of Certificate Authority(CA)
#
openssl req -new -x509 -keyout $PRIV/cakey.pem -out $DIR/cacert.pem \
-config $DIR/openssl.cnf
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Generating a 1024 bit RSA private key
# ................++++++
# .........++++++
# writing new private key to '/home/monty/openssl/private/cakey.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# You are about to be asked to enter information that will be
# incorporated into your certificate request.
# What you are about to enter is what is called a Distinguished Name
# or a DN.
# There are quite a few fields but you can leave some blank
# For some fields there will be a default value,
# If you enter '.', the field will be left blank.
# -----
# Country Name (2 letter code) [AU]:FI
# State or Province Name (full name) [Some-State]:.
# Locality Name (eg, city) []:
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
# Organizational Unit Name (eg, section) []:
# Common Name (eg, YOUR name) []:MySQL admin
# Email Address []:
#
# Create server request and key
#
openssl req -new -keyout $DIR/server-key.pem -out \
$DIR/server-req.pem -days 3600 -config $DIR/openssl.cnf
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Generating a 1024 bit RSA private key
# ..++++++
# ..........++++++
# writing new private key to '/home/monty/openssl/server-key.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# You are about to be asked to enter information that will be
# incorporated into your certificate request.
# What you are about to enter is what is called a Distinguished Name
# or a DN.
# There are quite a few fields but you can leave some blank
# For some fields there will be a default value,
# If you enter '.', the field will be left blank.
# -----
# Country Name (2 letter code) [AU]:FI
# State or Province Name (full name) [Some-State]:.
# Locality Name (eg, city) []:
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
# Organizational Unit Name (eg, section) []:
# Common Name (eg, YOUR name) []:MySQL server
# Email Address []:
#
# Please enter the following 'extra' attributes
# to be sent with your certificate request
# A challenge password []:
# An optional company name []:
#
# Remove the passphrase from the key (optional)
#
openssl rsa -in $DIR/server-key.pem -out $DIR/server-key.pem
#
# Sign server cert
#
openssl ca -policy policy_anything -out $DIR/server-cert.pem \
-config $DIR/openssl.cnf -infiles $DIR/server-req.pem
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Enter PEM pass phrase:
# Check that the request matches the signature
# Signature ok
# The Subjects Distinguished Name is as follows
# countryName :PRINTABLE:'FI'
# organizationName :PRINTABLE:'MySQL AB'
# commonName :PRINTABLE:'MySQL admin'
# Certificate is to be certified until Sep 13 14:22:46 2003 GMT
# (365 days)
# Sign the certificate? [y/n]:y
#
#
# 1 out of 1 certificate requests certified, commit? [y/n]y
# Write out database with 1 new entries
# Data Base Updated
#
# Create client request and key
#
openssl req -new -keyout $DIR/client-key.pem -out \
$DIR/client-req.pem -days 3600 -config $DIR/openssl.cnf
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Generating a 1024 bit RSA private key
# .....................................++++++
# .............................................++++++
# writing new private key to '/home/monty/openssl/client-key.pem'
# Enter PEM pass phrase:
# Verifying password - Enter PEM pass phrase:
# -----
# You are about to be asked to enter information that will be
# incorporated into your certificate request.
# What you are about to enter is what is called a Distinguished Name
# or a DN.
# There are quite a few fields but you can leave some blank
# For some fields there will be a default value,
# If you enter '.', the field will be left blank.
# -----
# Country Name (2 letter code) [AU]:FI
# State or Province Name (full name) [Some-State]:.
# Locality Name (eg, city) []:
# Organization Name (eg, company) [Internet Widgits Pty Ltd]:MySQL AB
# Organizational Unit Name (eg, section) []:
# Common Name (eg, YOUR name) []:MySQL user
# Email Address []:
#
# Please enter the following 'extra' attributes
# to be sent with your certificate request
# A challenge password []:
# An optional company name []:
#
# Remove a passphrase from the key (optional)
#
openssl rsa -in $DIR/client-key.pem -out $DIR/client-key.pem
#
# Sign client cert
#
openssl ca -policy policy_anything -out $DIR/client-cert.pem \
-config $DIR/openssl.cnf -infiles $DIR/client-req.pem
# Sample output:
# Using configuration from /home/monty/openssl/openssl.cnf
# Enter PEM pass phrase:
# Check that the request matches the signature
# Signature ok
# The Subjects Distinguished Name is as follows
# countryName :PRINTABLE:'FI'
# organizationName :PRINTABLE:'MySQL AB'
# commonName :PRINTABLE:'MySQL user'
# Certificate is to be certified until Sep 13 16:45:17 2003 GMT
# (365 days)
# Sign the certificate? [y/n]:y
#
#
# 1 out of 1 certificate requests certified, commit? [y/n]y
# Write out database with 1 new entries
# Data Base Updated
#
# Create a my.cnf file that you can use to test the certificates
#
cnf=""
cnf="$cnf [client]"
cnf="$cnf ssl-ca=$DIR/cacert.pem"
cnf="$cnf ssl-cert=$DIR/client-cert.pem"
cnf="$cnf ssl-key=$DIR/client-key.pem"
cnf="$cnf [mysqld]"
cnf="$cnf ssl-ca=$DIR/cacert.pem"
cnf="$cnf ssl-cert=$DIR/server-cert.pem"
cnf="$cnf ssl-key=$DIR/server-key.pem"
echo $cnf | replace " " '
' > $DIR/my.cnf
瑕佹兂娴嬭瘯SSL杩炴帴锛屾寜涓嬮潰鏂规硶鍚姩鏈嶅姟鍣紝鍏朵腑$DIR鏄ず渚my.cnf閫夐」鏂囦欢瀹夎鐨勮矾寰勫悕锛
shell> MySQLd --defaults-file=$DIR/my.cnf &
鐒跺悗浣跨敤鐩稿悓鐨勯夐」鏂囦欢璋冪敤瀹㈡埛绔▼搴忥細
shell> MySQL --defaults-file=$DIR/my.cnf
濡傛灉浣犳湁MySQL婧愮爜鍒嗗彂鐗堬紝杩樺彲浠ヤ慨鏀瑰墠闈㈢殑my.cnf鏂囦欢鏉ユ寚鍚SSL鐩綍涓殑绀鸿寖璇佷功鍜屽瘑閽ユ枃浠舵潵娴嬭瘯浣犵殑璁剧疆銆
MySQL鍙互妫鏌X509璇佷功鐨勫睘鎬у拰鍩轰簬鐢ㄦ埛鍚嶅拰瀵嗙爜鐨勯氱敤閴村畾鏂规硶銆傝鎯充负MySQL璐︽埛鎸囧畾SSL鐩稿叧閫夐」锛屼娇鐢GRANT璇彞鐨REQUIRE瀛愬彞銆傚弬瑙13.5.1.3鑺傦紝鈥淕RANT鍜孯EVOKE璇硶鈥銆
鏈夊绉嶅彲鑳芥潵闄愬埗涓涓处鎴风殑杩炴帴绫诲瀷锛
路 濡傛灉璐︽埛娌℃湁SSL鎴X509闇姹傦紝濡傛灉鐢ㄦ埛鍚嶅拰瀵嗙爜鍚堟硶锛屽厑璁告湭鍔犲瘑鐨勮繛鎺ャ備絾鏄紝濡傛灉瀹㈡埛鏈夋纭殑璇佷功鍜屽瘑閽ユ枃浠讹紝鍦ㄥ鎴烽夐」涓彲浠ヤ娇鐢ㄥ姞瀵嗚繛鎺ャ
路 REQUIRE SSL閫夐」闄愬埗鏈嶅姟鍣ㄥ彧鍏佽璇ヨ处鎴风殑SSL鍔犲瘑杩炴帴銆傝娉ㄦ剰濡傛灉鏈ACL璁板綍鍏佽闈SSL杩炴帴锛岃閫夐」浼氳蹇界暐銆
路 mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
路 -> IDENTIFIED BY 'goodsecret' REQUIRE SSL;
路 REQUIRE X509琛ㄧず瀹㈡埛蹇呴』鏈夊悎娉曡瘉涔︿絾纭垏鐨勮瘉涔︺佸垎鍙戣呭拰涓讳綋涓嶉噸瑕併傚敮涓鐨勯渶姹傛槸搴斿彲浠ヨ鏌愪釜CA璁よ瘉鏈烘瀯楠岃瘉瀹冪殑绛惧悕銆
路 mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
路 -> IDENTIFIED BY 'goodsecret' REQUIRE X509;
路 REQUIRE ISSUER 'issuer'闄愬埗杩炴帴浼佸浘锛屽嵆瀹㈡埛蹇呴』鍑虹ずCA 'issuer'绛惧彂鐨勫悎娉X509璇佷功銆傚鏋滃鎴峰嚭绀轰簡涓涓悎娉曡瘉涔︼紝浣嗘槸鏄敱涓嶅悓鐨勫垎鍙戣呯鍙戯紝鏈嶅姟鍣ㄦ嫆缁濊繛鎺ャ備娇鐢X509璇佷功琛ㄧず瑕佸姞瀵嗭紝鍥犳涓嶉渶瑕SSL閫夐」銆
路 mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
路 -> IDENTIFIED BY 'goodsecret'
路 -> REQUIRE ISSUER '/C=FI/ST=Some-State/L=Helsinki/
路 O=MySQL Finland AB/CN=Tonu Samuel/Email=tonu@example.com';
璇锋敞鎰ISSUER鍊煎簲鍋氫负鍗曚竴瀛楃涓茶緭鍏ャ
路 REQUIRE SUBJECT 'subject' 闄愬埗杩炴帴浼佸浘锛屽嵆瀹㈡埛蹇呴』鍑虹ず涓婚涓'subject'鐨勫悎娉X509璇佷功銆傚鏋滃鎴峰嚭绀轰簡涓涓悎娉曡瘉涔︼紝浣嗘槸鏈変笉鍚岀殑涓婚锛屾湇鍔″櫒鎷掔粷杩炴帴銆
路 mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
路 -> IDENTIFIED BY 'goodsecret'
路 -> REQUIRE SUBJECT '/C=EE/ST=Some-State/L=Tallinn/
路 O=MySQL demo client certificate/
CN=Tonu Samuel/Email=tonu@example.com';
璇锋敞鎰SUBJECT鍊煎簲鍋氫负鍗曚竴瀛楃涓茶緭鍏ャ
路 REQUIRE CIPHER 'cipher'鐢ㄦ潵纭繚浣跨敤瓒冲寮虹殑瀵嗙爜鍜屽瘑閽ラ暱搴︺傚鏋滀娇鐢ㄦ棫鐨勭煭鍔犲瘑瀵嗛挜绠楁硶锛SSL鏈韩鍙兘寰堝急銆備娇鐢ㄨ閫夐」锛屾垜浠彲浠ョ储鍙栫‘鍒囩殑鍔犲瘑鏂规硶鏉ヨ繛鎺ャ
路 mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
路 -> IDENTIFIED BY 'goodsecret'
-> REQUIRE CIPHER 'EDH-RSA-DES-CBC3-SHA';
鍦REQUIRE瀛愬彞涓紝鍙互缁撳悎浣跨敤SUBJECT銆ISSUER鍜CIPHER閫夐」锛
mysql> GRANT ALL PRIVILEGES ON test.* TO 'root'@'localhost'
-> IDENTIFIED BY 'goodsecret'
-> REQUIRE SUBJECT '/C=EE/ST=Some-State/L=Tallinn/
O=MySQL demo client certificate/
CN=Tonu Samuel/Email=tonu@example.com'
-> AND ISSUER '/C=FI/ST=Some-State/L=Helsinki/
O=MySQL Finland AB/CN=Tonu Samuel/Email=tonu@example.com'
-> AND CIPHER 'EDH-RSA-DES-CBC3-SHA';
璇锋敞鎰SUBJECT鍜ISSUER鍊煎簲鍋氫负鍗曚竴瀛楃涓茶緭鍏ャ
鍦MySQL 5.1涓,鍦REQUIRE閫夐」涔嬮棿鍙互閫夌敤AND鍏抽敭瀛椼
閫夐」鐨勯『搴忎笉閲嶈锛屼絾浠讳綍閫夐」涓嶈兘鐢ㄤ袱娆°
路 --ssl
瀵逛簬鏈嶅姟鍣紝璇ラ夐」瑙勫畾璇ユ湇鍔″櫒鍏佽SSL杩炴帴銆傚浜庡鎴风绋嬪簭锛屽畠鍏佽瀹㈡埛浣跨敤SSL杩炴帴鏈嶅姟鍣ㄣ傚崟鍗曡閫夐」涓嶈冻浠ヤ娇鐢SSL杩炴帴銆傝繕蹇呴』鎸囧畾--ssl-ca銆--ssl-cert鍜--ssl-key閫夐」銆
閫氬父浠庡弽鍚戜娇鐢ㄨ閫夐」琛ㄧず涓嶅簲浣跨敤SSL銆傝鎯冲疄鐜帮紝灏嗛夐」鎸囧畾涓--skip-ssl鎴--ssl=0銆
璇锋敞鎰忎娇鐢--ssl涓闇瑕SSL杩炴帴銆備緥濡傦紝濡傛灉缂栬瘧鐨勬湇鍔″櫒鎴栧鎴蜂笉鏀寔SSL锛屽垯浣跨敤鏅氱殑鏈姞瀵嗙殑杩炴帴銆
纭繚浣跨敤SSL杩炴帴鐨勫畨鍏ㄦ柟寮忔槸浣跨敤鍚REQUIRE SSL瀛愬彞鐨GRANT璇彞鍦ㄦ湇鍔″櫒涓婂垱寤轰竴涓处鎴枫傜劧鍚庝娇鐢ㄨ璐︽埛鏉ヨ繛鎺ユ湇鍔″櫒锛屾湇鍔″櫒鍜屽鎴风鍧囧簲鍚敤SSL鏀寔銆
路 --ssl-ca=file_name
鍚彲淇SSL CA鐨勬竻鍗曠殑鏂囦欢鐨勮矾寰勩
路 --ssl-capath=directory_name
鍖呭惈pem鏍煎紡鐨勫彲淇SSL CA璇佷功鐨勭洰褰曠殑璺緞銆
路 --ssl-cert=file_name
SSL璇佷功鏂囦欢鍚嶏紝鐢ㄤ簬寤虹珛瀹夊叏杩炴帴銆
路 --ssl-cipher=cipher_list
鍏佽鐨勭敤浜SSL鍔犲瘑鐨勫瘑鐮佺殑娓呭崟銆cipher_list鐨勬牸寮忎笌OpenSSL ciphers鍛戒护鐩稿悓銆
绀轰緥锛--ssl-cipher=ALL:-AES:-EXP
路 --ssl-key=file_name
SSL瀵嗛挜鏂囦欢鍚嶏紝鐢ㄤ簬寤虹珛瀹夊叏杩炴帴銆
1. 鍦Windows涓绘満涓婂畨瑁SSH瀹㈡埛绔備綔涓虹敤鎴凤紝鎴戞墍鍙戠幇鐨勬渶濂界殑闈炲厤璐瑰鎴风鏉ヨ嚜http://www.vandyke.com/鐨SecureCRT銆傚彟涓涓夊垯鏄http://www.f-secure.com/鐨f-secure銆備綘杩樺彲浠ヤ粠http://directory.google.com/Top/Computers/Security/Products_and_Tools/Cryptography/SSH/Clients/Windows/ 鐨Google鎵惧埌涓浜涘厤璐瑰鎴风銆
2. 鍚姩Windows SSH瀹㈡埛绔傝缃Host_Name = yourmysqlserver_URL_or_IP銆傝缃userid=your_userid浠ヤ究鐧诲綍鏈嶅姟鍣ㄣ傛userid鍊煎彲浠ヤ笌浣犵殑MySQL璐︽埛鐨勭敤鎴峰悕涓嶇浉鍚屻
3. 璁剧疆绔彛鏄犲皠銆傚彲浠ヨ繘琛岃繙绋嬫槧灏(璁剧疆local_port: 3306, remote_host: yourmysqlservername_or_ip, remote_port: 3306)鎴栨湰鍦版槧灏(璁剧疆port: 3306, host: localhost, remote port: 3306)銆
4. 杩涜淇濆瓨锛屽惁鍒欎笅娆¢渶瑕侀噸璁俱
5. 鍒氬垱寤虹殑SSH浼氳瘽鐧诲綍鏈嶅姟鍣ㄣ
6. 鍦Windows鏈哄櫒涓婂惎鍔ㄧ浉搴ODBC搴旂敤绋嬪簭(渚嬪Access)銆
7. 鍦Windows涓垱寤轰竴涓柊鐨勬枃浠舵寜鐓у父鐢ㄦ柟娉曢氳繃ODBC椹卞姩绋嬪簭閾炬帴MySQL锛屼笉鍚岀殑鏄涓MySQL鏈嶅姟鍣ㄨ緭鍏localhost锛岃屼笉鏄yourmysqlservername銆
浣犲簲鏈変娇鐢SSH鍔犲瘑鐨ODBC杩炴帴鍒MySQL銆
鏈妭璁ㄨ濡備綍杩涜鏁版嵁搴撳浠(瀹屽叏澶囦唤鍜屽閲忓浠)锛屼互鍙婂浣曟墽琛岃〃鐨勭淮鎶ゃ傛湰鑺傛弿杩扮殑SQL璇彞璇硶鍙傝绗5绔狅細鏁版嵁搴撶鐞銆傛澶勬彁渚涚殑澶у鏁颁俊鎭富瑕侀傚悎MyISAM琛ㄣInnoDB澶囦唤绋嬪簭鍙傝15.2.8鑺傦紝鈥淚nnoDB鏁版嵁搴撶殑澶囦唤鍜屾仮澶鈥銆
鍥犱负MySQL琛ㄤ繚瀛樹负鏂囦欢鏂瑰紡锛屽緢瀹规槗澶囦唤銆傝鎯充繚鎸佸浠界殑涓鑷存э紝瀵圭浉鍏宠〃鎵цLOCK TABLES鎿嶄綔锛岀劧鍚庡琛ㄦ墽琛FLUSH TABLES銆傚弬瑙13.4.5鑺傦紝鈥淟OCK TABLES鍜孶NLOCK TABLES璇硶鈥鍜13.5.5.2鑺傦紝鈥淔LUSH璇硶鈥銆備綘鍙渶瑕佽閿佸畾锛涜繖鏍峰綋浣犲鍒舵暟鎹簱鐩綍涓殑鏂囦欢鏃讹紝鍏佽鍏跺畠瀹㈡埛缁х画鏌ヨ琛ㄣ傞渶瑕FLUSH TABLES璇彞鏉ョ‘淇濆紑濮嬪浠藉墠灏嗘墍鏈夋縺娲荤殑绱㈠紩椤靛啓鍏ョ‖鐩樸
濡傛灉浣犳兂瑕佽繘琛SQL绾у埆鐨勮〃澶囦唤锛屼綘鍙互浣跨敤SELECT INTO ...OUTFILE鎴BACKUP TABLE銆傚浜SELECT INTO ...OUTFILE锛 杈撳嚭鐨勬枃浠朵笉鑳藉厛瀛樺湪銆傚浜BACKUP TABLE涔熷姝わ紝鍥犱负瑕嗙洊瀹屾暣鐨勬枃浠朵細鏈夊畨鍏ㄩ闄┿傚弬瑙13.2.7鑺傦紝鈥淪ELECT璇硶鈥鍜13.5.2.2鑺傦紝鈥淏ACKUP TABLE璇硶鈥銆
澶囦唤鏁版嵁搴撶殑鍙︿竴涓妧鏈槸浣跨敤mysqldump绋嬪簭鎴mysqlhotcopy鑴氭湰銆傚弬瑙8.8鑺傦紝鈥渕ysqldump锛氭暟鎹簱澶囦唤绋嬪簭鈥鍜8.9鑺傦紝鈥渕ysqlhotcopy锛氭暟鎹簱澶囦唤绋嬪簭鈥銆
1. 瀹屽叏澶囦唤鏁版嵁搴擄細
2. shell> mysqldump --tab=/path/to/some/dir --opt db_name
鎴栵細
shell> mysqlhotcopy db_name /path/to/some/dir
鍙鏈嶅姟鍣ㄤ笉鍐嶈繘琛屾洿鏂帮紝杩樺彲浠ュ彧澶嶅埗鎵鏈夎〃鏂囦欢(*.frm銆*.MYD鍜*.MYI鏂囦欢)銆mysqlhotcopy鑴氭湰浣跨敤璇ユ柟娉曘(浣嗚娉ㄦ剰濡傛灉鏁版嵁搴撳寘鍚InnoDB琛紝杩欎簺鏂规硶涓嶅伐浣溿InnoDB涓嶅皢琛ㄧ殑鍐呭淇濆瓨鍒版暟鎹簱鐩綍涓紝mysqlhotcopy鍙傚悎MyISAM琛級銆
3. 濡傛灉mysqld鍦ㄨ繍琛屽垯鍋滄锛岀劧鍚庣敤--log-bin[=file_name]閫夐」鏉ュ惎鍔ㄣ傚弬瑙5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆備簩杩涘埗鏃ュ織鏂囦欢涓彁渚涗簡 鎵цmysqldump涔嬪悗瀵规暟鎹簱鐨勬洿鏀硅繘琛屽鍒舵墍闇瑕佺殑淇℃伅銆
瀵逛簬InnoDB琛紝鍙互杩涜鍦ㄧ嚎澶囦唤锛屼笉闇瑕佸琛ㄨ繘琛岄攣瀹氾紱鍙傝8.8鑺傦紝鈥渕ysqldump锛氭暟鎹簱澶囦唤绋嬪簭鈥銆
MySQL鏀寔澧為噺澶囦唤:闇瑕佺敤--log-bin閫夐」鏉ュ惎鍔ㄦ湇鍔″櫒浠ヤ究鍚敤浜岃繘鍒舵棩蹇楋紱鍙傝5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆傚綋鎯宠杩涜澧為噺澶囦唤鏃(鍖呭惈涓婁竴娆″畬鍏ㄥ浠芥垨澧為噺澶囦唤涔嬪悗鐨勬墍鏈夋洿鏀)锛屽簲浣跨敤FLUSH LOGS鍥炴粴浜岃繘鍒舵棩蹇椼傜劧鍚庯紝浣犻渶瑕佸皢浠庢渶鍚庣殑瀹屽叏鎴栧閲忓浠界殑鏌愪釜鏃跺埢鍒版渶鍚庢煇涓偣鐨勬墍鏈変簩杩涘埗鏃ュ織澶嶅埗鍒板浠戒綅缃傝繖浜涗簩杩涘埗鏃ュ織涓哄閲忓浠斤紱鎭㈠鏃讹紝鎸夌収涓嬮潰鐨勮В閲婂簲鐢ㄣ備笅娆¤繘琛屽畬鍏ㄥ浠芥椂锛岃繕搴斾娇鐢FLUSH LOGS鎴mysqlhotcopy --flushlogs鍥炴粴浜岃繘鍒舵棩蹇椼傚弬瑙8.8鑺傦紝鈥渕ysqldump锛氭暟鎹簱澶囦唤绋嬪簭鈥鍜8.9鑺傦紝鈥渕ysqlhotcopy锛氭暟鎹簱澶囦唤绋嬪簭鈥銆
濡傛灉MySQL鏈嶅姟鍣ㄤ负浠庡鍒舵湇鍔″櫒锛屽垯鏃犺閫夋嫨浠涔堝浠芥柟娉曪紝褰撳浠戒粠鏈烘暟鎹椂锛岃繕搴斿浠master.info鍜relay-log.info鏂囦欢銆傛仮澶嶄簡浠庢満鏁版嵁鍚庯紝闇瑕佽繖浜涙枃浠舵潵缁х画澶嶅埗銆傚鏋滀粠鏈烘墽琛屽鍒LOAD DATA INFILE鍛戒护锛屼綘搴旇繕澶囦唤鐢--slave-load-tmpdir閫夐」鎸囧畾鐨勭洰褰曚腑鐨SQL_LOAD-*鏂囦欢銆(濡傛灉鏈寚瀹氾紝璇ヤ綅缃粯璁や负tmpdir鍙橀噺鍊硷級銆浠庢満闇瑕佽繖浜涙枃浠舵潵缁х画澶嶅埗涓柇鐨LOAD DATA INFILE鎿嶄綔銆
濡傛灉蹇呴』鎭㈠MyISAM琛紝鍏堜娇鐢REPAIR TABLE鎴myisamchk -r鏉ユ仮澶嶃99.9%鐨勬儏鍐典笅璇ユ柟娉曞彲浠ュ伐浣溿傚鏋myisamchk澶辫触锛岃瘯璇曚笅闈㈢殑鏂规硶銆傝娉ㄦ剰鍙湁鐢--log-bin閫夐」鍚姩浜MySQL浠庤屽惎鐢ㄤ簩杩涘埗鏃ュ織瀹冩墠宸ヤ綔锛涘弬瑙5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆
1. 鎭㈠鍘mysqldump澶囦唤锛屾垨浜岃繘鍒跺浠姐
2. 鎵ц涓嬮潰鐨勫懡浠ら噸鏂版洿鏂颁簩杩涘埗鏃ュ織锛
3. shell> mysqlbinlog hostname-bin.[0-9]* | mysql
鍦ㄦ煇浜涙儏鍐典笅锛屼綘鍙兘鍙兂瑕佷粠鏌愪釜浣嶇疆閲嶆柊杩愯鏌愪簺浜岃繘鍒舵棩蹇椼(閫氬父浣犳兂瑕佷粠鎭㈠澶囦唤鐨勬棩鏈熼噸鏂拌繍琛屾墍鏈変簩杩涘埗鏃ュ織锛屾煡璇笉姝g‘鏃朵緥澶)銆傚叧浜mysqlbinlog宸ュ叿鍜屽浣曚娇鐢ㄥ畠鐨勮缁嗕俊鎭弬瑙8.6鑺傦紝鈥渕ysqlbinlog锛氱敤浜庡鐞嗕簩杩涘埗鏃ュ織鏂囦欢鐨勫疄鐢ㄥ伐鍏封銆
杩樺彲浠ュ鍏蜂綋鏂囦欢杩涜閫夋嫨澶囦唤锛
路 瑕佹兂澶嶅埗琛紝浣跨敤SELECT * INTO OUTFILE 'file_name' FROM tbl_name銆
路 瑕佹兂閲嶈浇琛紝浣跨敤LOAD DATA INFILE 'file_name' REPLACE ...骞舵仮澶嶃傝閬垮厤澶嶅埗璁板綍锛岃〃蹇呴』鏈PRIMARY KEY鎴栦竴涓UNIQUE绱㈠紩銆傚綋鏂拌褰曞鍒跺敮涓閿肩殑鏃ц褰曟椂锛REPLACE鍏抽敭瀛楀彲浠ュ皢鏃ц褰曟浛鎹负鏂拌褰曘
濡傛灉澶囦唤鏃堕亣鍒版湇鍔″櫒鎬ц兘闂锛屽彲浠ユ湁甯姪鐨勪竴涓瓥鐣ユ槸鍦ㄤ粠鏈嶅姟鍣ㄨ屼笉鏄富鏈嶅姟鍣ㄤ笂寤虹珛澶嶅埗骞舵墽琛屽浠姐傚弬瑙6.1鑺傦紝鈥滃鍒朵粙缁嶁銆
濡傛灉浣跨敤Veritas鏂囦欢绯荤粺锛屽彲浠ヨ繖鏍峰浠斤細
1. 浠庡鎴风绋嬪簭鎵цFLUSH TABLES WITH READ LOCK銆
2. 浠庡彟涓涓shell鎵цmount vxfs snapshot銆
3. 浠庣涓涓鎴风鎵цUNLOCK TABLES銆
4. 浠庡揩鐓у鍒舵枃浠躲
5. 鍗歌浇蹇収銆
路 鎿嶄綔绯荤粺宕╂簝
路 鐢垫簮鏁呴殰
路 鏂囦欢绯荤粺宕╂簝
路 纭欢闂(纭洏銆佹瘝鏉跨瓑绛)
璇ュ懡浠や笉鍖呮嫭mysqldump鍜mysql绋嬪簭鐨--user鍜鈥password绛夐夐」銆傚簲鍖呮嫭蹇呰鐨勯夐」璁MySQL鏈嶅姟鍣ㄥ厑璁镐綘杩炴帴瀹冦
鎴戜滑鍋囧畾鏁版嵁淇濆瓨鍦MySQL鐨InnoDB瀛樺偍寮曟搸涓紝鏀寔浜嬪姟鍜岃嚜鍔ㄥ穿婧冩仮澶嶃傛垜浠亣瀹氬穿婧冩椂MySQL鏈嶅姟鍣ㄥ甫璐熻浇銆傚鏋滀笉甯﹁礋杞斤紝鍒欎笉闇瑕佹仮澶嶃
鍑虹幇鎿嶄綔绯荤粺宕╂簝鎴栫數婧愭晠闅滄椂锛屾垜浠彲浠ュ亣瀹氶噸鍚悗纭洏涓婄殑MySQL艣鏁版嵁浠嶅彲鐢ㄣ傜敱浜庡穿婧冿紝InnoDB鏁版嵁鏂囦欢涓殑鏁版嵁鍙兘涓嶅啀淇濇寔涓鑷存э紝浣InnoDB璇诲彇瀹冪殑鏃ュ織骞朵細鏌ュ埌鎸傝捣鐨勬彁浜ょ殑鍜屾湭鎻愪氦鐨勪簨鍔℃竻鍗曪紝瀹冧滑娌℃湁娓呯┖鍒版暟鎹枃浠朵腑銆InnoDB鑷姩鍗峰洖鏈彁浜ょ殑浜嬪姟锛屽苟娓呯┖鍒板畠鐨勬暟鎹枃浠朵腑銆傞氳繃MySQL閿欒鏃ュ織灏嗚鎭㈠杩囩▼鐩稿叧淇℃伅浼犺揪缁欑敤鎴枫備笅闈㈢殑渚嬪瓙涓烘棩蹇楁憳褰曪細
InnoDB: Database was not shut down normally.
InnoDB: Starting recovery from log files...
InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 13674004
InnoDB: Doing recovery: scanned up to log sequence number 0 13739520
InnoDB: Doing recovery: scanned up to log sequence number 0 13805056
InnoDB: Doing recovery: scanned up to log sequence number 0 13870592
InnoDB: Doing recovery: scanned up to log sequence number 0 13936128
...
InnoDB: Doing recovery: scanned up to log sequence number 0 20555264
InnoDB: Doing recovery: scanned up to log sequence number 0 20620800
InnoDB: Doing recovery: scanned up to log sequence number 0 20664692
InnoDB: 1 uncommitted transaction(s) which must be rolled back
InnoDB: Starting rollback of uncommitted transactions
InnoDB: Rolling back trx no 16745
InnoDB: Rolling back of trx no 16745 completed
InnoDB: Rollback of uncommitted transactions completed
InnoDB: Starting an apply batch of log records to the database...
InnoDB: Apply batch completed
InnoDB: Started
mysqld: ready for connections
濡傛灉鏂囦欢绯荤粺宕╂簝鎴栧嚭鐜扮‖浠堕棶棰橈紝鎴戜滑鍙互鍋囧畾閲嶅惎鍚庣‖鐩樹笂鐨MySQL艣鏁版嵁涓嶅彲鐢ㄣ傝繖璇存槑MySQL鏈兘鎴愬姛鍚姩锛屽洜涓轰竴浜涚‖鐩樻暟鎹潡涓嶅啀鍙銆傚湪杩欑鎯呭喌涓嬶紝闇瑕侀噸鏂版牸寮忓寲纭洏锛屽畨瑁呬竴涓柊鐨勶紝鎴栫籂姝i棶棰樸傜劧鍚庨渶瑕佷粠澶囦唤涓仮澶MySQL鏁版嵁锛岃繖璇存槑鎴戜滑蹇呴』鍏堝仛濂藉浠姐傝鎯崇‘淇濓紝搴斿強鏃惰繑鍥炲苟璁捐澶囦唤绛栫暐銆
鎴戜滑閮界煡閬撳繀椤绘寜璁″垝瀹氭湡杩涜澶囦唤銆傚彲浠ョ敤鍑犱釜宸ュ叿瀹屽叏澶囦唤(鍦ㄦ煇涓椂闂寸偣鐨勬暟鎹揩鐓)MySQL銆備緥濡傦紝InnoDB Hot Backup涓InnoDB鏁版嵁鏂囦欢鎻愪緵鍦ㄧ嚎闈炴暟鎹潡鐗╃悊澶囦唤锛mysqldump鎻愪緵鍦ㄧ嚎閫昏緫澶囦唤銆傝繖閲屼娇鐢mysqldump銆
鍋囧畾鎴戜滑鍦ㄦ槦鏈熸棩涓嬪崍1鐐硅繘琛屼簡澶囦唤锛屾鏃惰礋鑽疯緝浣庛備笅闈㈢殑鍛戒护鍙互瀹屽叏澶囦唤鎵鏈夋暟鎹簱涓殑鎵鏈InnoDB琛細
shell> mysqldump --single-transaction --all-databases > backup_sunday_1_PM.sql
杩欐槸鍦ㄧ嚎闈炲潡澶囦唤锛屼笉浼氬共鎵板琛ㄧ殑璇诲啓銆鎴戜滑浠ュ墠鍋囧畾鎴戜滑鐨勮〃涓InnoDB琛紝鍥犳--single-transaction浣跨敤涓鑷存у湴璇伙紝骞朵笖淇濊瘉mysqldump鎵鐪嬭鐨鏁版嵁涓嶄細鏇存敼銆(鍏跺畠瀹㈡埛绔InnoDB琛ㄨ繘琛岀殑鏇存敼涓嶄細琚mysqldump杩涚▼鐪嬭锛銆濡傛灉鎴戜滑杩樻湁鍏跺畠绫诲瀷鐨勮〃锛屾垜浠繀椤诲亣瀹氬湪澶囦唤杩囩▼涓畠浠笉浼氭洿鏀广備緥濡傦紝瀵逛簬mysql鏁版嵁搴撲腑鐨MyISAM琛锛屾垜浠繀椤诲亣瀹氬湪澶囦唤杩囩▼涓病鏈夊MySQL璐︽埛杩涜绠$悊鏇存敼銆
mysqldump鍛戒护浜х敓鐨.sql鏂囦欢鍖呭惈涓绯诲垪SQL INSERT璇彞锛屽彲浠ョ敤鏉ラ噸杞借浆鍌ㄧ殑琛ㄣ
闇瑕佽繘琛屽畬鍏ㄥ浠斤紝浣嗘湁鏃朵笉鏂逛究銆備細浜х敓澶х殑澶囦唤鏂囦欢骞堕渶瑕佽姳鏃堕棿鏉ョ敓鎴愩備粠鏌愪釜瑙掑害锛屽畬鍏ㄥ浠藉苟涓嶇悊鎯筹紝鍥犱负姣忎釜鎴愬姛鐨勫畬鍏ㄥ浠藉寘鎷墍鏈夋暟鎹紝鐢氳嚦鑷粠涓婁竴娆″畬鍏ㄥ浠戒互鏉ユ病鏈夋洿鏀圭殑閮ㄥ垎銆傚畬鎴愪簡鍒濅娇瀹屽叏澶囦唤鍚庯紝杩涜澧為噺澶囦唤浼氭洿鏈夋晥銆傝繖鏍峰浠芥枃浠惰灏忓緱澶氾紝澶囦唤鏃堕棿涔熻緝鐭備笉鍒╀箣澶勬槸锛屾仮澶嶆椂涓嶈兘鍙噸杞藉畬鍏ㄥ浠芥潵鎭㈠鏁版嵁銆傝繕蹇呴』瑕佺敤澧為噺澶囦唤鏉ユ仮澶嶅閲忔洿鏀广
瑕佹兂杩涜澧為噺澶囦唤锛屾垜浠渶瑕佷繚瀛樺閲忔洿鏀广傚簲浣跨敤--log-bin閫夐」鍚姩MySQL鏈嶅姟鍣紝浠ヤ究鏇存柊鏁版嵁鏃跺皢杩欎簺鏇存敼淇濆瓨鍒版枃浠朵腑銆傝閫夐」鍚敤浜岃繘鍒舵棩蹇楋紝鍥犳鏈嶅姟鍣ㄥ啓灏嗘瘡涓洿鏂版暟鎹殑SQL璇彞鍐欏叆MySQL浜岃繘鍒舵棩蹇椼傝鎴戜滑鐪嬬湅鐢--log-bin閫夐」鍚姩鐨勫凡缁忚繍琛屽鏃ョ殑MySQL鏈嶅姟鍣ㄧ殑鏁版嵁鐩綍銆傛垜浠壘鍒颁互涓MySQL浜岃繘鍒舵棩蹇楁枃浠讹細
-rw-rw---- 1 guilhem guilhem 1277324 Nov 10 23:59 gbichot2-bin.000001
-rw-rw---- 1 guilhem guilhem 4 Nov 10 23:59 gbichot2-bin.000002
-rw-rw---- 1 guilhem guilhem 79 Nov 11 11:06 gbichot2-bin.000003
-rw-rw---- 1 guilhem guilhem 508 Nov 11 11:08 gbichot2-bin.000004
-rw-rw---- 1 guilhem guilhem 220047446 Nov 12 16:47 gbichot2-bin.000005
-rw-rw---- 1 guilhem guilhem 998412 Nov 14 10:08 gbichot2-bin.000006
-rw-rw---- 1 guilhem guilhem 361 Nov 14 10:07 gbichot2-bin.index
姣忔閲嶅惎锛MySQL鏈嶅姟鍣ㄧ敤搴忓垪涓殑涓嬩竴涓紪鍙峰垱寤轰竴涓柊鐨勪簩杩涘埗鏃ュ織鏂囦欢銆傚綋鏈嶅姟鍣ㄨ繍琛屾椂锛屼綘杩樺彲浠ラ氳繃鎵цFLUSH LOGS SQL璇彞鎴mysqladmin flush-logs鍛戒护锛屽憡璇夋湇鍔″櫒鍏抽棴褰撳墠鐨勪簩杩涘埗鏃ュ織鏂囦欢骞跺垱寤轰竴涓柊鏂囦欢銆mysqldump涔熸湁涓涓夐」鏉ユ竻绌烘棩蹇椼傛暟鎹洰褰曚腑鐨.index鏂囦欢鍖呭惈璇ョ洰褰曚笅鎵鏈MySQL浜岃繘鍒舵棩蹇楃殑娓呭崟銆傝鏂囦欢鐢ㄤ簬澶嶅埗銆
鎭㈠鏃MySQL浜岃繘鍒舵棩蹇楀緢閲嶈锛屽洜涓哄畠浠槸澧為噺澶囦唤銆傚鏋滆繘琛屽畬鍏ㄥ浠芥椂纭繚娓呯┖浜嗘棩蹇楋紝鍒欏悗闈㈠垱寤虹殑浜岃繘鍒舵棩蹇楁枃浠跺寘鍚簡澶囦唤鍚庣殑鎵鏈夋暟鎹洿鏀广傝鎴戜滑绋嶇◢淇敼鍓嶉潰鐨mysqldump鍛戒护锛岃瀹冨湪瀹屽叏澶囦唤鏃惰兘澶熸竻绌 MySQL浜岃繘鍒舵棩蹇楋紝浠ヤ究杞偍鏂囦欢鍖呭惈鍖呭惈鏂扮殑褰撳墠鐨勪簩杩涘埗鏃ュ織锛
shell> mysqldump --single-transaction --flush-logs --master-data=2
--all-databases > backup_sunday_1_PM.sql
鎵ц璇ュ懡浠ゅ悗锛屾暟鎹洰褰曞垯鍖呭惈鏂扮殑浜岃繘鍒舵棩蹇楁枃浠讹紝gbichot2-bin.000007銆傜粨鏋.sql鏂囦欢鍖呭惈涓嬪垪琛岋細
-- Position to start replication or point-in-time 鎭㈠鏃y from
-- CHANGE MASTER TO MASTER_LOG_FILE='gbichot2-bin.000007',MASTER_LOG_POS=4;
鍥犱负mysqldump鍛戒护鍙互鎵ц瀹屽叏澶囦唤锛岃繖浜涜琛ㄧず涓や欢浜嬫儏锛
路 .sql鏂囦欢鍖呭惈鎵鏈夊啓鍏gbichot2-bin.000007浜岃繘鍒舵棩蹇楁枃浠舵垨鏈鏂扮殑鏂囦欢涔嬪墠鐨勬洿鏀广
路 澶囦唤鍚庢墍璁板綍鐨勬墍鏈夋暟鎹洿鏀逛笉鍑虹幇鍦.sql涓紝浣嗗嚭鐜板湪gbichot2-bin.000007浜岃繘鍒舵棩蹇楁枃浠舵垨鏈鏂扮殑鏂囦欢涓
鍦ㄦ槦鏈熶竴涓嬪崍1鐐癸紝鎴戜滑鍙互娓呯┖鏃ュ織寮濮嬫柊鐨勪簩杩涘埗鏃ュ織鏂囦欢鏉ュ垱寤哄閲忓浠姐備緥濡傦紝鎵цmysqladmin flush-logs鍛戒护鍒涘缓gbichot2-bin.000008銆傛槦鏈熸棩涓嬪崍1鐐圭殑瀹屽叏澶囦唤鍜屾槦鏈熶竴涓嬪崍1鐐逛箣闂寸殑鎵鏈夋洿鏀逛负鏂囦欢gbichot2-bin.000007銆傝澧為噺澶囦唤寰堥噸瑕侊紝鍥犳鏈濂藉皢瀹冨鍒跺埌瀹夊叏鐨勫湴鏂广(渚嬪锛屽浠藉埌纾佸甫鎴DVD涓婏紝鎴栧鍒跺埌鍙︿竴鍙版満鍣ㄤ笂锛銆鍦ㄦ槦鏈熶簩涓嬪崍1鐐癸紝鎵ц鍙︿竴涓mysqladmin flush-logs鍛戒护銆傛槦鏈熶竴涓嬪崍1鐐瑰拰鏄熸湡浜屼笅鍗1鐐逛箣闂寸殑鎵鏈夋墍鏈夋洿鏀逛负鏂囦欢gbichot2-bin.000008(涔熷簲澶嶅埗鍒版煇涓畨鍏ㄧ殑鍦版柟)銆
MySQL浜岃繘鍒舵棩蹇楀崰鎹‖鐩樼┖闂淬傝鎯抽噴鏀剧┖闂达紝搴旈殢鏃舵竻绌恒傛搷浣滄柟娉曟槸鍒犳帀涓嶅啀浣跨敤鐨勪簩杩涘埗鏃ュ織锛屼緥濡傝繘琛屽畬鍏ㄥ浠芥椂锛
shell> mysqldump --single-transaction --flush-logs --master-data=2
--all-databases --delete-master-logs > backup_sunday_1_PM.sql
娉閲婏細濡傛灉浣犵殑鏈嶅姟鍣ㄤ负澶嶅埗涓绘湇鍔″櫒锛岀敤mysqldump --delete-master-logs鍒犳帀MySQL浜岃繘鍒舵棩蹇楀緢鍗遍櫓锛屽洜涓轰粠鏈嶅姟鍣ㄥ彲鑳借繕娌℃湁瀹屽叏澶勭悊璇ヤ簩杩涘埗鏃ュ織鐨勫唴瀹广
PURGE MASTER LOGS璇彞鐨勬弿杩颁腑瑙i噴浜嗕负浠涔堝湪鍒犳帀MySQL浜岃繘鍒舵棩蹇椾箣鍓嶅簲杩涜纭銆傚弬瑙13.6.1.1鑺傦紝鈥淧URGE MASTER LOGS璇硶鈥銆
鐜板湪鍋囪鍦ㄦ槦鏈熶笁涓婂崍8鐐瑰嚭鐜颁簡鐏鹃毦鎬у穿婧冿紝闇瑕佷娇鐢ㄥ浠芥枃浠惰繘琛屾仮澶嶃傛仮澶嶆椂锛屾垜浠鍏堟仮澶嶆渶鍚庣殑瀹屽叏澶囦唤(浠庢槦鏈熸棩涓嬪崍1鐐瑰紑濮)銆傚畬鍏ㄥ浠芥枃浠舵槸涓绯诲垪SQL璇彞锛屽洜姝ゆ仮澶嶅畠寰堝鏄擄細
shell> mysql < backup_sunday_1_PM.sql
鍦ㄨ鐐癸紝鏁版嵁鎭㈠鍒版槦鏈熸棩涓嬪崍1鐐圭殑鐘舵併傝鎯虫仮澶嶄粠閭f椂璧风殑鏇存敼锛屾垜浠繀椤讳娇鐢ㄥ閲忓浠斤紝涔熷氨鏄紝gbichot2-bin.000007鍜gbichot2-bin.000008浜岃繘鍒舵棩蹇楁枃浠躲傛牴鎹渶瑕佷粠澶囦唤澶勫彇杩囪繖浜涙枃浠讹紝鐒跺悗鎸変笅杩版柟寮忓鐞嗭細
shell> mysqlbinlog gbichot2-bin.000007 gbichot2-bin.000008 | mysql
鎴戜滑鐜板湪灏嗘暟鎹仮澶嶅埌鏄熸湡浜屼笅鍗1鐐圭殑鐘舵侊紝浣嗘槸浠庤鏃跺埢鍒板穿婧冧箣闂寸殑鏁版嵁浠嶇劧鏈変涪澶便傝鎯虫仮澶嶏紝鎴戜滑闇瑕MySQL鏈嶅姟鍣ㄥ皢MySQL浜岃繘鍒舵棩蹇椾繚瀛樺埌瀹夊叏鐨勪綅缃(RAID disks, SAN, ...)锛屽簲涓轰笌鏁版嵁鏂囦欢鐨勪繚瀛樹綅缃笉鍚岀殑鍦版柟锛屼繚璇佽繖浜涙棩蹇椾笉鍦ㄦ瘉鍧忕殑纭洏涓娿(涔熷氨鏄紝鎴戜滑鍙互鐢--log-bin閫夐」鍚姩鏈嶅姟鍣紝鎸囧畾涓涓叾瀹冪墿鐞嗚澶囦笂鐨勪笌鏁版嵁鐩綍涓嶅悓鐨勪綅缃傝繖鏍凤紝鍗充娇鍖呭惈璇ョ洰褰曠殑璁惧涓㈠け锛屾棩蹇椾篃涓嶄細涓㈠け锛銆濡傛灉鎴戜滑鎵ц浜嗚繖浜涙搷浣滐紝鎴戜滑鎵嬪ご涓婁細鏈gbichot2-bin.000009鏂囦欢锛屾垜浠彲浠ョ敤瀹冩潵鎭㈠澶ч儴鍒嗘渶鏂扮殑鏁版嵁鏇存敼锛岃屼笉浼氫涪澶卞埌宕╂簝鏃剁殑鏁版嵁銆
鍑虹幇鎿嶄綔绯荤粺宕╂簝鎴栫數婧愭晠闅滄椂锛InnoDB鑷繁鍙互瀹屾垚鎵鏈夋暟鎹仮澶嶅伐浣溿備絾涓轰簡纭繚浣犲彲浠ョ潯濂借锛屽簲閬典粠涓嬮潰鐨勬寚瀵硷細
路 涓瀹氱敤--log-bin鎴栫敋鑷--log-bin=log_name閫夐」杩愯MySQL鏈嶅姟鍣紝鍏朵腑鏃ュ織鏂囦欢鍚嶄綅浜庢煇涓畨鍏ㄥ獟浠嬩笂锛屼笉鍚屼簬鏁版嵁鐩綍鎵鍦ㄩ┍鍔ㄥ櫒銆傚鏋滀綘鏈夎繖鏍风殑瀹夊叏濯掍粙锛屾渶濂借繘琛岀‖鐩樿礋杞藉潎琛(杩欐牱鑳藉鎻愰珮鎬ц兘)銆
路 瀹氭湡杩涜瀹屽叏澶囦唤锛屼娇鐢mysqldump鍛戒护杩涜鍦ㄧ嚎闈炲潡澶囦唤銆
路 鐢FLUSH LOGS鎴mysqladmin flush-logs娓呯┖鏃ュ織杩涜瀹氭湡澧為噺澶囦唤銆
濡傛灉MySQL鏈嶅姟鍣ㄥ惎鐢ㄤ簡浜岃繘鍒舵棩蹇楋紝浣犲彲浠ヤ娇鐢mysqlbinlog宸ュ叿鏉ユ仮澶嶄粠鎸囧畾鐨勬椂闂寸偣寮濮 (渚嬪锛屼粠浣犳渶鍚庝竴娆″浠)鐩村埌鐜板湪鎴栧彟涓涓寚瀹氱殑鏃堕棿鐐圭殑鏁版嵁銆傚叧浜庡惎鐢ㄤ簩杩涘埗鏃ュ織鐨勪俊鎭紝鍙傝5.11.3鑺傦紝鈥滀簩杩涘埗鏃ュ織鈥銆傚浜mysqlbinlog鐨勮缁嗕俊鎭紝鍙傝8.6鑺傦紝鈥渕ysqlbinlog锛氱敤浜庡鐞嗕簩杩涘埗鏃ュ織鏂囦欢鐨勫疄鐢ㄥ伐鍏封銆
瑕佹兂浠庝簩杩涘埗鏃ュ織鎭㈠鏁版嵁锛屼綘闇瑕佺煡閬撳綋鍓嶄簩杩涘埗鏃ュ織鏂囦欢鐨勮矾寰勫拰鏂囦欢鍚嶃備竴鑸彲浠ヤ粠閫夐」鏂囦欢(鍗my.cnf or my.ini锛屽彇鍐充簬浣犵殑绯荤粺)涓壘鍒拌矾寰勩傚鏋滄湭鍖呭惈鍦ㄩ夐」鏂囦欢涓紝褰撴湇鍔″櫒鍚姩鏃讹紝鍙互鍦ㄥ懡浠よ涓互閫夐」鐨勫舰寮忕粰鍑恒傚惎鐢ㄤ簩杩涘埗鏃ュ織鐨勯夐」涓--log-bin銆傝鎯崇‘瀹氬綋鍓嶇殑浜岃繘鍒舵棩蹇楁枃浠剁殑鏂囦欢鍚嶏紝杈撳叆涓嬮潰鐨MySQL璇彞锛
SHOW BINLOG EVENTS \G
浣犺繕鍙互浠庡懡浠よ杈撳叆涓嬮潰鐨勫唴瀹癸細
mysql --user=root -pmy_pwd -e 'SHOW BINLOG EVENTS \G'
灏嗗瘑鐮my_pwd鏇挎崲涓烘湇鍔″櫒鐨root瀵嗙爜銆
mysqlbinlog --stop-date="2005-04-20 9:59:59" /var/log/mysql/bin.123456 \
| mysql -u root -pmypwd
璇ュ懡浠ゅ皢鎭㈠鎴鍒板湪--stop-date閫夐」涓互DATETIME鏍煎紡缁欏嚭鐨勬棩鏈熷拰鏃堕棿鐨勬墍鏈夋暟鎹傚鏋滀綘娌℃湁妫娴嬪埌鍑犱釜灏忔椂鍚庤緭鍏ョ殑閿欒鐨SQL璇彞锛屽彲鑳戒綘鎯宠鎭㈠鍚庨潰鍙戠敓鐨勬椿鍔ㄣ傛牴鎹繖浜涳紝浣犲彲浠ョ敤璧蜂娇鏃ユ湡鍜屾椂闂村啀娆¤繍琛mysqlbinlog锛
mysqlbinlog --start-date="2005-04-20 10:01:00" /var/log/mysql/bin.123456 \
| mysql -u root -pmypwd \
鍦ㄨ琛屼腑锛屼粠涓婂崍10:01鐧诲綍鐨SQL璇彞灏嗚繍琛屻傜粍鍚堟墽琛屽墠澶滅殑杞偍鏂囦欢鍜mysqlbinlog鐨勪袱琛屽彲浠ュ皢鎵鏈夋暟鎹仮澶嶅埌涓婂崍10:00鍓嶄竴绉掗挓銆備綘搴旀鏌ユ棩蹇椾互纭繚鏃堕棿纭垏銆備笅涓鑺備粙缁嶅浣曞疄鐜般
mysqlbinlog --start-date="2005-04-20 9:55:00" --stop-date="2005-04-20 10:05:00" \
/var/log/mysql/bin.123456 > /tmp/mysql_restore.sql
璇ュ懡浠ゅ皢鍦/tmp鐩綍鍒涘缓灏忕殑鏂囨湰鏂囦欢锛屽皢鏄剧ず鎵ц浜嗛敊璇殑SQL璇彞鏃剁殑SQL璇彞銆備綘鍙互鐢ㄦ枃鏈紪杈戝櫒鎵撳紑璇ユ枃浠讹紝瀵绘壘浣犱笉瑕佹兂閲嶅鐨勮鍙ャ傚鏋滀簩杩涘埗鏃ュ織涓殑浣嶇疆鍙风敤浜庡仠姝㈠拰缁х画鎭㈠鎿嶄綔锛屽簲杩涜娉ㄩ噴銆傜敤log_pos鍔犱竴涓暟瀛楁潵鏍囪浣嶇疆銆備娇鐢ㄤ綅缃彿鎭㈠浜嗕互鍓嶇殑澶囦唤鏂囦欢鍚庯紝浣犲簲浠庡懡浠よ杈撳叆涓嬮潰鍐呭锛
mysqlbinlog --stop-position="368312" /var/log/mysql/bin.123456 \
| mysql -u root -pmypwd
mysqlbinlog --start-position="368315" /var/log/mysql/bin.123456 \
| mysql -u root -pmypwd \
涓婇潰鐨勭1琛屽皢鎭㈠鍒板仠姝綅缃负姝㈢殑鎵鏈変簨鍔°備笅涓琛屽皢鎭㈠浠庣粰瀹氱殑璧峰浣嶇疆鐩村埌浜岃繘鍒舵棩蹇楃粨鏉熺殑鎵鏈変簨鍔°傚洜涓mysqlbinlog鐨勮緭鍑哄寘鎷瘡涓SQL璇彞璁板綍涔嬪墠鐨SET TIMESTAMP璇彞锛屾仮澶嶇殑鏁版嵁鍜岀浉鍏MySQL鏃ュ織灏嗗弽搴斾簨鍔℃墽琛岀殑鍘熸椂闂淬
鍚庨潰鍑犺妭璁ㄨ濡備綍浣跨敤myisamchk鏉ユ鏌ユ垨缁存姢MyISAM琛(瀵瑰簲.MYI鍜.MYD鏂囦欢鐨勮〃)銆
浣犲彲浠ヤ娇鐢myisamchk瀹炵敤绋嬪簭鏉ヨ幏寰楁湁鍏充綘鐨勬暟鎹簱琛ㄧ殑淇℃伅鎴栨鏌ャ佷慨澶嶃佷紭鍖栦粬浠備笅鍒楀皬鑺傛弿杩板浣曡皟鐢myisamchk锛堝寘鎷畠鐨勯夐」鐨勬弿杩帮級锛屽浣曞缓绔嬭〃鐨勭淮鎶よ鍒掞紝浠ュ強濡備綍浣跨敤myisamchk鎵ц鍚勭鍔熻兘銆
灏界鐢myisamchk淇琛ㄥ緢瀹夊叏锛屽湪淇(鎴栦换浣曞彲浠ュぇ閲忔洿鏀硅〃鐨勭淮鎶ゆ搷浣)涔嬪墠鍏堣繘琛屽浠涔熸槸寰堝ソ鐨勪範鎯
褰卞搷绱㈠紩鐨myisamchk鎿嶄綔浼氫娇ULLTEXT绱㈠紩鐢full-text鍙傛暟閲嶅缓锛屼笉鍐嶄笌MySQL鏈嶅姟鍣ㄤ娇鐢ㄧ殑鍊煎吋瀹广傝鎯抽伩鍏嶏紝璇烽槄璇5.9.5.1鑺傦紝鈥滅敤浜巑yisamchk鐨勪竴鑸椤鈥鐨勮鏄庛
鍦ㄨ澶氭儏鍐典笅锛屼綘浼氬彂鐜颁娇鐢SQL璇彞瀹炵幇MyISAM琛ㄧ殑缁存姢姣旀墽琛myisamchk鎿嶄綔瑕佸鏄撳湴澶氾細
路 瑕佹兂妫鏌ユ垨缁存姢MyISAM琛紝浣跨敤CHECK TABLE鎴REPAIR TABLE銆
路 瑕佹兂浼樺寲MyISAM琛紝浣跨敤OPTIMIZE TABLE銆
路 瑕佹兂鍒嗘瀽MyISAM琛紝浣跨敤ANALYZE TABLE銆
鍙互鐩存帴杩欎簺璇彞锛屾垨浣跨敤mysqlcheck瀹㈡埛绔▼搴忥紝鍙互鎻愪緵鍛戒护琛屾帴鍙c
杩欎簺璇彞姣myisamchk鏈夊埄鐨勫湴鏂规槸鏈嶅姟鍣ㄥ彲浠ュ仛浠讳綍宸ヤ綔銆備娇鐢myisamchk锛屼綘蹇呴』纭繚鏈嶅姟鍣ㄥ湪鍚屼竴鏃堕棿涓嶄娇鐢ㄨ〃銆傚惁鍒欙紝myisamchk鍜屾湇鍔″櫒涔嬮棿浼氬嚭鐜颁笉鏈熸湜鐨勭浉浜掑共娑夈
鍙互浣跨敤myisamchk瀹炵敤绋嬪簭鏉ヨ幏寰楁湁鍏虫暟鎹簱琛ㄧ殑淇℃伅鎴栨鏌ャ佷慨澶嶃佷紭鍖栦粬浠myisamchk閫傜敤MyISAM琛(瀵瑰簲.MYI鍜.MYD鏂囦欢鐨勮〃)銆
璋冪敤myisamchk鐨勬柟娉曪細
shell> myisamchk [options] tbl_name ...
options鎸囧畾浣犳兂璁myisamchk鍋氫粈涔堛傚湪鍚庨潰鎻忚堪瀹冧滑銆傝繕鍙互閫氳繃璋冪敤myisamchk --help寰楀埌閫夐」鍒楄〃銆
tbl_name鏄綘鎯宠妫鏌ユ垨淇鐨勬暟鎹簱琛ㄣ傚鏋滀綘涓嶅湪鏁版嵁搴撶洰褰曠殑鏌愬杩愯myisamchk锛屼綘蹇呴』鎸囧畾鏁版嵁搴撶洰褰曠殑璺緞锛屽洜涓myisamchk涓嶇煡閬撲綘鐨勬暟鎹簱浣嶄簬鍝効銆傚疄闄呬笂锛myisamchk涓嶅湪涔庝綘姝e湪鎿嶄綔鐨勬枃浠舵槸鍚︿綅浜庝竴涓暟鎹簱鐩綍锛涗綘鍙互灏嗗搴斾簬鏁版嵁搴撹〃鐨勬枃浠舵嫹璐濆埌鍒骞朵笖鍦ㄩ偅閲屾墽琛屾仮澶嶆搷浣溿
濡傛灉浣犳効鎰忥紝鍙互鐢myisamchk鍛戒护琛屽懡鍚嶅嚑涓〃銆傝繕鍙互閫氳繃鍛藉悕绱㈠紩鏂囦欢(鐢鈥 .MYI鈥鍚庣紑)鏉ユ寚瀹氫竴涓〃銆傚畠鍏佽浣犻氳繃浣跨敤妯″紡鈥*.MYI鈥鎸囧畾鍦ㄤ竴涓洰褰曟墍鏈夌殑琛ㄣ備緥濡傦紝濡傛灉浣犲湪鏁版嵁搴撶洰褰曪紝鍙互杩欐牱鍦ㄧ洰褰曚笅妫鏌ユ墍鏈夌殑MyISAM琛細
shell> myisamchk *.MYI
濡傛灉浣犱笉鍦ㄦ暟鎹簱鐩綍涓嬶紝鍙氳繃鎸囧畾鍒扮洰褰曠殑璺緞妫鏌ユ墍鏈夊湪閭i噷鐨勮〃锛
shell> myisamchk /path/to/database_dir/*.MYI
浣犵敋鑷冲彲浠ラ氳繃涓MySQL鏁版嵁鐩綍鐨勮矾寰勬寚瀹氫竴涓氶厤绗︽潵妫鏌ユ墍鏈夌殑鏁版嵁搴撲腑鐨勬墍鏈夎〃锛
shell> myisamchk /path/to/datadir/*/*.MYI
鎺ㄨ崘鐨勫揩閫熸鏌ユ墍鏈MyISAM琛ㄧ殑鏂瑰紡鏄細
shell> myisamchk --silent --fast /path/to/datadir/*/*.MYI
濡傛灉浣犳兂瑕佹鏌ユ墍鏈MyISAM琛ㄥ苟淇浠讳綍鐮村潖鐨勮〃锛屽彲浠ヤ娇鐢ㄤ笅闈㈢殑鍛戒护锛
shell> myisamchk --silent --force --fast --update-state \
-O key_buffer=64M -O sort_buffer=64M \
-O read_buffer=1M -O write_buffer=1M \
/path/to/datadir/*/*.MYI
璇ュ懡浠ゅ亣瀹氫綘鏈夊ぇ浜64MB鐨勮嚜鐢卞唴瀛樸傚叧浜庣敤myisamchk鍒嗛厤鍐呭瓨鐨勮缁嗕俊鎭紝鍙傝5.9.5.5鑺傦紝鈥myisamchk鍐呭瓨浣跨敤鈥銆
褰撲綘杩愯myisamchk鏃讹紝蹇呴』纭繚鍏跺畠绋嬪簭涓嶄娇鐢ㄨ〃銆傚惁鍒欙紝褰撲綘杩愯myisamchk鏃讹紝浼氭樉绀轰笅闈㈢殑閿欒娑堟伅锛
warning: clients are using or haven't closed the table properly
杩欒鏄庝綘姝e皾璇曟鏌ユ琚彟涓涓繕娌℃湁鍏抽棴鏂囦欢鎴栧凡缁忕粓姝㈣屾病鏈夋纭湴鍏抽棴鏂囦欢鐨勭▼搴(渚嬪mysqld鏈嶅姟鍣)鏇存柊鐨勮〃銆
濡傛灉mysqld姝e湪杩愯锛屼綘蹇呴』閫氳繃FLUSH TABLES寮哄埗娓呯┖浠嶇劧鍦ㄥ唴瀛樹腑鐨勪换浣曡〃淇敼銆傚綋浣犺繍琛myisamchk鏃讹紝蹇呴』纭繚鍏跺畠绋嬪簭涓嶄娇鐢ㄨ〃銆傞伩鍏嶈闂鐨勬渶瀹规槗鐨勬柟娉曟槸浣跨敤CHECK TABLE鑰屼笉鐢myisamchk鏉ユ鏌ヨ〃銆
鏈妭鎻忚堪鐨勯夐」鍙互鐢ㄤ簬鐢myisamchk鎵ц鐨勪换浣曠被鍨嬬殑琛ㄧ淮鎶ゆ搷浣溿傛湰鑺傚悗闈㈢殑绔犺妭涓弿杩扮殑閫夐」鍙傚悎鍏蜂綋鎿嶄綔锛屼緥濡傛鏌ユ垨淇琛ㄣ
路 --help锛-?
鏄剧ず甯姪娑堟伅骞堕鍑恒
路 --debug=debug_options, -# debug_options
杈撳嚭璋冭瘯璁板綍鏂囦欢銆debug_options瀛楃涓茬粡甯告槸'd:t:o,filename'銆
路 --silent锛-s
娌夐粯妯″紡銆備粎褰撳彂鐢熼敊璇椂鍐欒緭鍑恒備綘鑳戒娇鐢-s涓ゆ(-ss)浣myisamchk娌夐粯銆
路 --verbose锛-v
鍐楅暱妯″紡銆傛墦鍗版洿澶氱殑淇℃伅銆傝繖鑳戒笌-d鍜-e涓璧蜂娇鐢ㄣ備负浜嗘洿鍐楅暱锛屼娇鐢-v澶氭(-vv, -vvv)锛
路 --version, -V
鏄剧ず鐗堟湰淇℃伅骞堕鍑恒
路 --wait, -w
濡傛灉琛ㄨ閿佸畾锛屼笉鏄彁绀洪敊璇粓姝紝鑰屾槸鍦ㄧ户缁墠绛夊緟鍒拌〃琚В閿併傝娉ㄦ剰濡傛灉鐢--skip-external-locking閫夐」杩愯mysqld锛屽彧鑳界敤鍙︿竴涓myisamchk鍛戒护閿佸畾琛ㄣ
杩樺彲浠ラ氳繃--var_name=value閫夐」璁剧疆涓嬮潰鐨勫彉閲忥細
鍙橀噺 |
榛樿鍊 |
decode_bits |
9 |
ft_max_word_len |
鍙栧喅浜庣増鏈 |
ft_min_word_len |
4 |
ft_stopword_file |
鍐呭缓鍒楄〃 |
key_buffer_size |
523264 |
myisam_block_size |
1024 |
read_buffer_size |
262136 |
sort_buffer_size |
2097144 |
sort_key_blocks |
16 |
stats_method |
nulls_unequal |
write_buffer_size |
262136 |
鍙互鐢myisamchk --help妫鏌myisamchk鍙橀噺鍙婂叾 榛樿鍊硷細
褰撶敤鎺掑簭閿间慨澶嶉敭鍊兼椂浣跨敤sort_buffer_size锛屼娇鐢--recover鏃惰繖鏄緢鏅氱殑鎯呭喌銆
褰撶敤--extend-check妫鏌ヨ〃鎴栭氳繃涓琛屼竴琛屽湴灏嗛敭鍊兼彃鍏ヨ〃涓(濡傚悓鏅氭彃鍏)鏉ヤ慨鏀归敭鍊兼椂浣跨敤Key_buffer_size銆傚湪浠ヤ笅鎯呭喌閫氳繃閿肩紦鍐插尯杩涜淇锛
路 浣跨敤--safe-recover銆
路 褰撶洿鎺ュ垱寤洪敭鍊兼枃浠舵椂锛岄渶瑕佸閿兼帓搴忕殑涓存椂鏂囦欢鏈変袱鍊嶅ぇ銆傞氬父鏄綋CHAR銆VARCHAR銆佹垨TEXT鍒楃殑閿艰緝澶х殑鎯呭喌锛屽洜涓烘帓搴忔搷浣滃湪澶勭悊杩囩▼涓渶瑕佷繚瀛樺叏閮ㄩ敭鍊笺傚鏋滀綘鏈夊ぇ閲忎复鏃剁┖闂达紝鍙互閫氳繃鎺掑簭寮哄埗浣跨敤myisamchk鏉ヤ慨澶嶏紝鍙互浣跨敤--sort-recover閫夐」銆
閫氳繃閿肩紦鍐插尯鐨勪慨澶嶅崰鐢ㄧ殑纭洏绌洪棿姣斾娇鐢ㄦ帓搴忎箞灏戯紝浣嗘槸瑕佹參銆
濡傛灉鎯宠蹇熶慨澶嶏紝灏key_buffer_size鍜sort_buffer_size鍙橀噺璁剧疆鍒板ぇ绾﹀彲鐢ㄥ唴瀛樼殑25%銆傚彲浠ュ皢涓や釜鍙橀噺璁剧疆涓鸿緝澶х殑鍊硷紝鍥犱负涓涓椂闂村彧浣跨敤涓涓彉閲忋
myisam_block_size鏄敤浜庣储寮曞潡鐨勫唴瀛樺ぇ灏忋
stats_method褰卞搷褰撶粰瀹--analyze閫夐」鏃讹紝濡備綍涓虹储寮曠粺璁℃悳闆嗗鐞NULL鍊笺傚畠濡傚悓myisam_stats_method绯荤粺鍙橀噺銆傝缁嗕俊鎭弬瑙5.3.3鑺傦紝鈥滄湇鍔″櫒绯荤粺鍙橀噺鈥鍜7.4.7鑺傦紝鈥淢yISAM绱㈠紩缁熻闆嗗悎鈥鐨myisam_stats_method鐨勬弿杩般
ft_min_word_len鍜ft_max_word_len琛ㄧずFULLTEXT绱㈠紩鐨勬渶灏忓拰鏈澶у瓧闀裤ft_stopword_file涓哄仠姝㈠瓧鏂囦欢鐨勬枃浠跺悕銆傞渶瑕佸湪浠ヤ笅鐜涓鍏惰繘琛岃缃
濡傛灉浣犱娇鐢myisamchk鏉ヤ慨鏀硅〃绱㈠紩(渚嬪淇鎴栧垎鏋)锛屼娇鐢ㄦ渶灏忓拰鏈澶у瓧闀垮拰鍋滄瀛楁枃浠剁殑 榛樿鍏ㄦ枃鍙傛暟鍊硷紙闄ら潪浣犲彟澶栨寚瀹氾級閲嶅缓FULLTEXT绱㈠紩銆傝繖鏍蜂細瀵艰嚧鏌ヨ澶辫触銆
鍑虹幇杩欎簺闂鏄洜涓哄彧鏈夋湇鍔″櫒鐭ラ亾杩欎簺鍙傛暟銆傚畠浠病鏈変繚瀛樺湪MyISAM绱㈠紩鏂囦欢涓傚鏋滀綘淇敼浜嗘湇鍔″櫒涓殑鏈灏忔垨鏈澶у瓧闀挎垨鍋滄瀛楁枃浠讹紝瑕侀伩鍏嶈闂锛屼负鐢ㄤ簬mysqld鐨myisamchk鎸囧畾鐩稿悓鐨ft_min_word_len锛ft_max_word_len鍜ft_stopword_file鍊笺備緥濡傦紝濡傛灉浣犲皢鏈灏忓瓧闀胯缃负3,鍙互杩欐牱浣跨敤myisamchk鏉ヤ慨澶嶈〃锛
shell> myisamchk --recover --ft_min_word_len=3 tbl_name.MYI
瑕佹兂纭繚myisamchk鍜屾湇鍔″櫒浣跨敤鐩稿悓鐨勫叏鏂囧弬鏁板硷紝鍙互灏嗗畠浠斁鍏ラ夐」鏂囦欢鐨[mysqld]鍜[myisamchk]灏忚妭锛
[mysqld]
ft_min_word_len=3
[myisamchk]
ft_min_word_len=3
闄や簡myisamchk锛岃繕鍙互浣跨敤REPAIR TABLE銆ANALYZE TABLE銆OPTIMIZE TABLE鎴ALTER TABLE銆傝繖浜涜鍙ョ敱鏈嶅姟鍣ㄦ墽琛岋紝鐭ラ亾瑕佷娇鐢ㄧ殑姝g‘鐨勫叏鏂囧弬鏁板笺
myisamchk鏀寔涓嬮潰鐨勮〃妫鏌ユ搷浣滈夐」锛
路 --check, -c
妫鏌ヨ〃鐨勯敊璇傚鏋滀綘涓嶆槑纭寚瀹氭搷浣滅被鍨嬮夐」锛岃繖灏辨槸榛樿鎿嶄綔銆
路 --check-only-changed, -C
鍙鏌ヤ笂娆℃鏌ュ悗鏈夊彉鏇寸殑琛ㄣ
路 --extend-check, -e
闈炲父浠旂粏鍦版鏌ヨ〃銆傚鏋滆〃鏈夎澶氱储寮曞皢浼氱浉褰撴參銆傝閫夐」鍙兘鐢ㄤ簬鏋佺鎯呭喌銆備竴鑸儏鍐典笅锛屽彲浠ヤ娇鐢myisamchk鎴myisamchk --medium-check鏉ョ‘瀹氳〃鍐呮槸鍚︽湁閿欒銆
濡傛灉浣犱娇鐢ㄤ簡--extend-check骞朵笖鏈夊厖鍒嗙殑鍐呭瓨锛屽皢key_buffer_size鍙橀噺璁剧疆涓鸿緝澶х殑鍊煎彲浠ヤ娇淇鎿嶄綔杩愯寰楁洿蹇
路 --fast锛-F
鍙鏌ユ病鏈夋纭叧闂殑琛ㄣ
路 --force, -f
濡傛灉myisamchk鍙戠幇琛ㄥ唴鏈変换浣曢敊璇紝鍒欒嚜鍔ㄨ繘琛屼慨澶嶃傜淮鎶ょ被鍨嬩笌--repair鎴-r閫夐」鎸囧畾鐨勭浉鍚屻
路 --information, -i
鎵撳嵃鎵妫鏌ヨ〃鐨勭粺璁′俊鎭
路 --medium-check, -m
姣--extend-check鏇村揩閫熷湴杩涜妫鏌ャ傚彧鑳藉彂鐜99.99%鐨勯敊璇紝鍦ㄥぇ澶氭暟鎯呭喌涓嬪氨瓒冲浜嗐
路 --read-only, -T
涓嶈灏嗚〃鏍囪涓哄凡缁忔鏌ャ傚鏋滀綘浣跨敤myisamchk鏉ユ鏌ユ琚叾瀹冨簲鐢ㄧ▼搴忎娇鐢ㄨ屾病鏈夐攣瀹氱殑琛ㄥ緢鏈夌敤锛屼緥濡傚綋鐢--skip-external-locking閫夐」杩愯鏃惰繍琛mysqld銆
路 --update-state, -U
灏嗕俊鎭繚瀛樺湪.MYI鏂囦欢涓紝鏉ヨ〃绀鸿〃妫鏌ョ殑鏃堕棿浠ュ強鏄惁琛ㄥ穿婧冧簡銆傝閫夐」鐢ㄦ潵鍏呭垎鍒╃敤--check-only-changed閫夐」锛屼絾濡傛灉mysqld鏈嶅姟鍣姝d娇鐢ㄨ〃骞朵笖姝g敤--skip-external-locking閫夐」杩愯鏃朵笉搴斾娇鐢ㄨ閫夐」銆
myisamchk鏀寔涓嬮潰鐨勮〃淇鎿嶄綔鐨勯夐」锛
路 --backup, -B
灏.MYD鏂囦欢澶囦唤涓file_name-time.BAK
路 --character-sets-dir=path
瀛楃闆嗗畨瑁呯洰褰曘傚弬瑙5.10.1鑺傦紝鈥滄暟鎹拰鎺掑簭鐢ㄥ瓧绗﹂泦鈥銆
路 --correct-checksum
绾犳琛ㄧ殑鏍¢獙鍜屼俊鎭
路 --data-file-length=len, -D len
鏁版嵁鏂囦欢鐨勬渶澶ч暱搴(褰撻噸寤烘暟鎹枃浠朵笖涓衡滄弧鈥濇椂)銆
路 --extend-check锛-e
杩涜淇锛岃瘯鍥句粠鏁版嵁鏂囦欢鎭㈠姣忎竴琛屻備竴鑸儏鍐典細鍙戠幇澶ч噺鐨勫瀮鍦捐銆備笉瑕佷娇鐢ㄨ閫夐」,闄ら潪浣犱笉椤惧悗鏋溿
路 --force, -f
瑕嗙洊鏃х殑涓棿鏂囦欢(鏂囦欢鍚嶇被浼tbl_name.TMD)锛岃屼笉鏄腑鏂
路 --keys-used=val, -k val
瀵逛簬myisamchk锛岃閫夐」鍊间负浣嶅硷紝璇存槑瑕佹洿鏂扮殑绱㈠紩銆傞夐」鍊肩殑姣忎竴涓簩杩涘埗浣嶅搴旇〃鐨勪竴涓储寮曪紝鍏朵腑绗竴涓储寮曞搴斾綅0銆傞夐」鍊0绂佺敤瀵规墍鏈夌储寮曠殑鏇存柊锛屽彲浠ヤ繚璇佸揩閫熸彃鍏ャ傞氳繃myisamchk -r鍙互閲嶆柊婵娲昏绂佺敤鐨勭储寮曘
路 --no-symlinks, -l
涓嶈窡闅忕鍙疯繛鎺ャ傞氬父myisamchk淇涓涓鍙疯繛鎺ユ墍鎸囩殑琛ㄣ傚湪MySQL 4.0涓閫夐」涓嶅瓨鍦紝鍥犱负浠4.0寮濮嬬殑鐗堟湰鍦ㄤ慨澶嶈繃绋嬩腑涓嶇Щ闄ょ鍙烽摼鎺ャ
路 --parallel-recover, -p
涓-r鍜-n鐨勭敤娉曠浉鍚岋紝浣嗕娇鐢ㄤ笉鍚岀殑绾跨▼骞惰鍒涘缓鎵鏈夐敭銆杩欐槸alpha浠g爜銆傝嚜宸辨壙鎷呴闄╋紒
路 --quick锛-q
涓嶄慨鏀规暟鎹枃浠讹紝蹇熻繘琛屼慨澶嶃傚嚭鐜板鍒堕敭鏃讹紝浣犲彲浠ヤ袱娆℃寚瀹氳椤逛互寮哄埗myisamchk淇敼鍘熸暟鎹枃浠躲
路 --recover, -r
鍙互淇鍑犱箮鎵鏈変竴鍒囬棶棰橈紝闄ら潪鍞竴鐨勯敭涓嶅敮涓鏃(瀵逛簬MyISAM琛紝杩欐槸闈炲父涓嶅彲鑳界殑鎯呭喌)銆傚鏋滀綘鎯宠鎭㈠琛紝杩欐槸棣栧厛瑕佸皾璇曠殑閫夐」銆傚鏋myisamchk鎶ュ憡琛ㄤ笉鑳界敤-r鎭㈠锛屽垯鍙兘灏濊瘯-o銆傚湪涓嶅お鍙兘鐨勬儏鍐典笅-r澶辫触锛屾暟鎹枃浠朵繚鎸佸畬濂斤級銆
濡傛灉浣犳湁澶ч噺鍐呭瓨锛屼綘搴斿鍔sort_buffer_size鐨勫銆
路 --safe-recover, -o
浣跨敤涓涓佺殑鎭㈠鏂规硶璇诲彇锛屾寜椤哄簭璇诲彇鎵鏈夎锛屽苟鏍规嵁鎵惧埌鐨勮鏇存柊鎵鏈夌储寮曟爲銆傝繖姣-r鎱簺锛屼絾鏄兘澶勭悊-r涓嶈兘澶勭悊鐨勬儏鍐点傝鎭㈠鏂规硶浣跨敤鐨勭‖鐩樼┖闂存瘮-r灏戙備竴鑸儏鍐碉紝浣犲簲棣栧厛鐢-r缁翠慨锛屽鏋-r澶辫触鍒欑敤-o銆
濡傛灉浣犳湁澶ч噺鍐呭瓨锛屼綘搴斿鍔sort_buffer_size鐨勫銆
路 (OBSOLETE) --set-character-set=name
鍦MySQL 5.1涓笉浣跨敤銆傚弬瑙--set-collation銆
路 --set-collation=name
鏇存敼鐢ㄦ潵鎺掑簭琛ㄧ储寮曠殑鏍″瑙勫垯銆傛牎瀵硅鍒欏悕鐨勭涓閮ㄥ垎鍖呭惈瀛楃闆嗗悕銆
路 --sort-recover, -n
寮哄埗myisamchk閫氳繃鎺掑簭鏉ヨВ鏋愰敭鍊硷紝鍗充娇涓存椂鏂囦欢灏嗗彲鑳藉緢澶с
路 --tmpdir=path, -t path
鐢ㄤ簬淇濆瓨涓存椂鏂囦欢鐨勭洰褰曠殑璺緞銆傚鏋滄湭璁剧疆锛myisamchk浣跨敤TMPDIR鐜鍙橀噺鐨勫笺tmpdir鍙互璁剧疆涓轰竴绯诲垪鐩綍璺緞锛岀敤浜庢垚鍔熷湴浠round-robin妯″紡鍒涘缓涓存椂鏂囦欢銆傚湪Unix涓紝鐩綍鍚嶄箣闂寸殑闂撮殧瀛楃涓哄啋鍙(鈥:鈥)锛屽湪Windows銆NetWare鍜OS/2涓负鍒嗗彿 (鈥锛鈥)銆
路 --unpack锛-u
灏嗙敤myisampack鎵撳寘鐨勮〃瑙e寘銆
路 --analyze锛-a
鍒嗘瀽閿肩殑鍒嗗竷銆傝繖閫氳繃璁╄仈缁撲紭鍖栧櫒鏇村ソ鍦伴夋嫨琛ㄥ簲璇ヤ互浠涔堟搴忚仈缁撳拰搴旇浣跨敤鍝釜閿潵鏀硅繘鑱旂粨鎬ц兘銆傝鎯宠幏鍙栧垎甯冪浉鍏充俊鎭紝浣跨敤myisamchk --description --verbose tbl_name鍛戒护鎴SHOW KEYS FROM tbl_name璇彞銆
路 --description, -d
鎵撳嵃鍑哄叧浜庤〃鐨勬弿杩版т俊鎭
路 --set-auto-increment[=value], -A[value]
寮哄埗浠庣粰瀹氬煎紑濮嬬殑鏂拌褰曚娇鐢AUTO_INCREMENT缂栧彿(鎴栧鏋滃凡缁忔湁AUTO_INCREMENT鍊煎ぇ灏忕殑璁板綍锛屽簲浣跨敤鏇撮珮鍊)銆傚鏋滄湭鎸囧畾value锛屾柊璁板綍鐨AUTO_INCREMENT缂栧彿搴斾娇鐢ㄥ綋鍓嶈〃鐨勬渶澶у煎姞涓1銆
路 --sort-index, -S
浠ヤ粠楂樺埌浣庣殑椤哄簭鎺掑簭绱㈠紩鏍戝潡銆傝繖灏嗕紭鍖栨悳瀵诲苟涓斿皢浣挎寜閿肩殑琛ㄦ壂鎻忔洿蹇
路 --sort-records=N, -R N
鏍规嵁涓涓叿浣撶储寮曟帓搴忚褰曘傝繖浣夸綘鐨勬暟鎹洿灞閮ㄥ寲骞朵笖鍙互鍔犲揩鍦ㄨ閿笂鐨SELECT鍜ORDER BY鐨勮寖鍥存悳绱€傦紙绗竴娆″仛鎺掑簭鍙兘寰堟參锛侊級涓轰簡鎵惧嚭涓寮犺〃鐨勭储寮曠紪鍙凤紝浣跨敤SHOW INDEX锛屽畠浠myisamchk鐪嬭浠栦滑鐨勭浉鍚岄『搴忔樉绀轰竴寮犺〃鐨勭储寮曘傜储寮曚粠1寮濮嬬紪鍙枫
濡傛灉閿病鏈夋墦鍖(PACK_KEYS=0)锛屽畠浠殑闀垮害鐩稿悓锛屽洜姝ゅ綋myisamchk 鎺掑簭骞剁Щ鍔ㄨ褰曟椂锛屽彧瑕嗙洊绱㈠紩涓殑璁板綍鍋忕Щ閲忋傚鏋滈敭宸茬粡鎵撳寘(PACK_KEYS=1)锛myisamchk蹇呴』鍏堣В寮鎵撳寘鐨勯敭鍧楋紝鐒跺悗閲嶆柊鍒涘缓绱㈠紩骞跺啀娆″皢閿潡鎵撳寘銆(鍦ㄨ繖绉嶆儏鍐典笅锛岄噸鏂板垱寤虹储寮曟瘮鏇存柊姣忎釜绱㈠紩鐨勫亸绉婚噺瑕佸揩锛銆
褰撲綘杩愯myisamchk鏃跺唴瀛樺垎閰嶉噸瑕.MYIsamchk浣跨敤鐨勫唴瀛樺ぇ灏忎笉鑳借秴杩囩敤-O閫夐」鎸囧畾鐨勩傚鏋滀綘鎯冲姣忎竴涓ぇ琛ㄤ娇鐢myisamchk锛屼綘蹇呴』棣栧厛纭畾浣犳兂浣跨敤澶氬皯鍐呭瓨銆備慨澶嶆椂鍙互浣跨敤鐨 榛樿鍊煎彧鏈3MB銆備娇鐢ㄦ洿澶х殑鍐呭瓨锛屽彲浠ヨmyisamchk宸ヤ綔寰楁洿蹇竴浜涖備緥濡傦紝濡傛灉鏈夊ぇ浜32MB鐨RAM锛屽彲浠ヤ娇鐢ㄥ涓嬫墍绀洪夐」(闄や簡浣犲彲浠ユ寚瀹氱殑鍏跺畠閫夐」)锛
shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
瀵逛簬澶у鏁版儏鍐碉紝浣跨敤-O sort=16M搴旇瓒冲浜嗐
搴旇浣myisamchk浣跨敤TMPDIR涓殑涓存椂鏂囦欢銆傚鏋TMPDIR鎸囧悜鍐呭瓨鏂囦欢绯荤粺锛屼綘鍙兘寰堝鏄撳緱鍒板唴瀛樻孩鍑虹殑閿欒銆傚鏋滃彂鐢燂紝璁惧畾TMPDIR鎸囧悜鏈夋洿澶氱┖闂寸殑鏂囦欢绯荤粺鐩綍骞朵笖閲嶅惎myisamchk銆
淇鏃myisamchk涔熼渶瑕佸ぇ閲忕‖鐩樼┖闂达細
路 灏嗘暟鎹枃浠跺ぇ灏忔墿澶т竴鍊(鍘熸枃浠跺拰澶嶅埗鏂囦欢)銆傚鏋滀綘鐢--quick淇鍒欎笉闇瑕佽绌洪棿锛涘湪杩欑鎯呭喌涓嬶紝鍙噸鏂板垱寤轰簡绱㈠紩鏂囦欢銆傚湪鏂囦欢绯荤粺涓婇渶瑕佺殑绌洪棿涓庡師鏁版嵁鏂囦欢鐩稿悓锛(鍒涘缓鐨勫鍒舵枃浠朵綅浜庡師鏂囦欢鎵鍦ㄧ洰褰曪級銆
路 浠f浛鏃х储寮曟枃浠剁殑鏂扮储寮曟枃浠舵墍鍗犵┖闂淬備慨澶嶅伐浣滀竴寮濮嬶紝灏卞鏃х储寮曟枃浠惰繘琛屼簡鍒犲噺锛屽洜姝や綘閫氬父浼氬拷鐣ヨ绌洪棿銆傚湪鏂囦欢绯荤粺涓婇渶瑕佺殑璇ョ┖闂翠笌鍘熸暟鎹枃浠剁浉鍚岋紒
路 褰撲娇鐢--recover鎴---sort-recover(浣嗕笉浣跨敤--safe-recover)鏃讹紝闇瑕佹帓搴忕紦鍐插尯绌洪棿銆傞渶瑕佺殑绌洪棿涓猴細
路 (largest_key + row_pointer_length) * number_of_rows * 2
鍙互鐢myisamchk -dv tbl_name妫鏌ラ敭鍊煎拰row_pointer_length鐨勯暱搴︺傚湪涓存椂鐩綍鍒嗛厤璇ョ┖闂(鐢TMPDIR鎴--tmpdir=path鎸囧畾)銆
濡傛灉鍦ㄤ慨澶嶈繃绋嬩腑鍑虹幇纭洏绌洪棿闂锛屽彲浠ヨ瘯璇曠敤--safe-recover浠f浛--recover銆
濡傛灉鐢--skip-external-locking杩愯mysqld(鍦ㄦ煇浜涚郴缁熶笂涓 榛樿璁剧疆锛屼緥濡Linux)锛屽綋mysqld浣跨敤鏌愪釜琛ㄦ椂锛屼綘涓嶈兘鍙潬鍦颁娇鐢myisamchk鏉ユ鏌ョ浉鍚岀殑琛ㄣ傚綋浣犺繍琛myisamchk鏃跺鏋滃彲浠ョ‘淇濇病鏈変汉鍦ㄩ氳繃mysqld璁块棶琛紝鍦ㄥ紑濮嬫鏌ヨ〃鍓嶏紝浣犲彧闇瑕佽繍琛mysqladmin flush-tables銆傚鏋滀綘涓嶈兘淇濊瘉锛屽垯浣犳鏌ヨ〃鏃朵綘蹇呴』鍋滄mysqld銆傚鏋mysqld鏇存柊琛ㄦ椂杩愯myisamchk锛屼綘鍙兘浼氳幏寰楄〃琚牬鍧忕殑璀﹀憡锛屽嵆浣夸簨瀹炲苟闈炲姝ゃ
濡傛灉涓嶄娇鐢--skip-external-locking锛屽彲浠ラ殢鏃朵娇鐢myisamchk鏉ユ鏌ヨ〃銆傚綋妫鏌ヨ〃鏃讹紝鎵鏈夊皾璇曟洿鏂拌〃鐨勫鎴风灏嗙瓑寰咃紝鐩村埌myisamchk鍑嗗濂藉彲浠ョ户缁
濡傛灉浣跨敤myisamchk鏉ヤ慨澶嶆垨浼樺寲琛紝蹇呴』纭繚mysqld鏈嶅姟鍣娌℃湁鍦ㄤ娇鐢ㄨ琛(濡傛灉浣犳浣跨敤--skip-external-locking閫夐」涔熼傜敤)銆傚鏋滀笉鍏抽棴mysqld锛屽湪杩愯myisamchk涔嬪墠鑷冲皯搴旀墽琛mysqladmin flush-tables銆傚鏋滄湇鍔″櫒鍜myisamchk鍚屾椂璁块棶琛紝琛鍙兘浼氳鐮村潖銆
鏈妭鎻忚堪濡備綍妫鏌ュ拰澶勭悊MySQL鏁版嵁搴撲腑鐨勬暟鎹牬鍧忋傚鏋滆〃缁忓父琚牬鍧忥紝浣犲簲灏藉姏鎵惧埌鍘熷洜銆傚弬瑙A.4.2鑺傦紝鈥滃鏋淢ySQL渚濈劧宕╂簝锛屽簲浣滀簺浠涔堚銆
鍏充簬MyISAM琛ㄦ庢牱浼氳鐮村潖鐨勮В閲婏紝鍙傝15.1.4鑺傦紝鈥淢yISAM琛ㄦ柟闈㈢殑闂鈥銆
鍦ㄦ墽琛屽穿婧冩仮澶嶆椂锛岀悊瑙e湪涓涓暟鎹簱涓殑姣忎竴涓MyISAM琛tbl_name瀵瑰簲鐨勫湪鏁版嵁搴撶洰褰曚腑鐨3涓枃浠舵槸寰堥噸瑕佺殑锛
鏂囦欢 |
鐩殑 |
tbl_name.frm |
瀹氫箟(鏍煎紡)鏂囦欢 |
tbl_name.MYD |
鏁版嵁鏂囦欢 |
tbl_name.MYI |
绱㈠紩鏂囦欢 |
杩3绫绘枃浠剁殑姣忎竴绫婚兘鍙兘閬彈涓嶅悓褰㈠紡鐨勬崯鍧忥紝浣嗘槸闂鏈甯稿彂鐢熷湪鏁版嵁鏂囦欢鍜岀储寮曟枃浠躲
myisamchk閫氳繃涓琛屼竴琛屽湴鍒涘缓涓涓鈥.MYD鈥鏁版嵁鏂囦欢鐨勫壇鏈潵宸ヤ綔锛屽畠閫氳繃鍒犻櫎鏃х殑鈥.MYD 鏂囦欢骞朵笖閲嶅懡鍚嶆柊鏂囦欢鍒板師鏉ョ殑鏂囦欢鍚嶇粨鏉熶慨澶嶉樁娈点傚鏋滀綘浣跨敤--quick锛myisamchk涓嶅垱寤轰竴涓复鏃鈥.MYD鈥鏂囦欢锛屽彧鏄亣瀹鈥.MYD鈥鏂囦欢鏄纭殑骞朵笖浠呭垱寤轰竴涓柊鐨勭储寮曟枃浠讹紝涓嶆帴瑙鈥.MYD鈥鏂囦欢锛岃繖鏄畨鍏ㄧ殑锛屽洜涓myisamchk鑷姩妫娴鈥.MYD鈥鏂囦欢鏄惁鎹熷潖骞朵笖鍦ㄨ繖绉嶆儏鍐典笅锛屾斁寮冧慨澶嶃備綘涔熷彲浠ョ粰myisamchk涓や釜--quick閫夐」銆傚湪杩欑鎯呭喌涓嬶紝myisamchk涓嶄細鍦ㄤ竴浜涢敊璇笂(璞¢噸澶嶉敭)鏀惧純锛岀浉鍙嶈瘯鍥鹃氳繃淇敼鈥.MYD鈥鏂囦欢瑙e喅瀹冧滑銆傞氬父锛屽彧鏈夊湪澶皯鐨勭┖闂茬鐩樼┖闂翠笂瀹炴柦姝e父淇锛屼娇鐢ㄤ袱涓--quick閫夐」鏃舵墠鏈夌敤銆傚湪杩欑鎯呭喌涓嬶紝浣犺嚦灏戝簲璇ュ湪杩愯myisamchk鍓嶅仛杩涜澶囦唤銆
路 myisamchk tbl_name
杩欐牱鑳芥壘鍑99.99%鐨勯敊璇傚畠涓嶈兘鎵惧嚭鐨勬槸浠呬粎娑夊強鏁版嵁鏂囦欢鐨勬崯鍧(杩欏緢涓嶅父瑙)銆傚鏋滄兂瑕佹鏌ヤ竴寮犺〃锛岄氬父搴旇娌℃湁閫夐」鍦拌繍琛myisamchk鎴栫敤-s鎴--silent閫夐」鐨勪换浣曚竴涓
路 myisamchk -m tbl_name
杩欐牱鑳芥壘鍑99.99%鐨勯敊璇傚畠棣栧厛妫鏌ユ墍鏈夌储寮曟潯鐩殑閿欒骞堕氳鎵鏈夎銆傚畠杩樿绠楄鍐呮墍鏈夐敭鍊肩殑鏍¢獙鍜岋紝骞剁‘璁ゆ牎楠屽拰涓庣储寮曟爲鍐呴敭鐨勬牎楠屽拰鐩稿尮閰嶃
路 myisamchk -e tbl_name
鍙互瀹屽叏褰诲簳鍦版鏌ユ暟鎹(-e鎰忔濇槸鈥滄墿灞曟鏌モ)銆傚畠瀵规瘡涓琛屽仛姣忎釜閿殑璇绘鏌ヤ互璇佸疄瀹冧滑纭疄鎸囧悜姝g‘鐨勮銆傝繖鍦ㄤ竴涓湁寰堝閿殑澶ц〃涓婂彲鑳借姳寰堥暱鏃堕棿銆myisamchk閫氬父灏嗗湪瀹冨彂鐜扮涓涓敊璇互鍚庡仠姝€傚鏋滀綘鎯宠鑾峰緱鏇村鐨勪俊鎭紝鍙互澧炲姞--verbose(-v)閫夐」銆傝繖浣垮緱myisamchk缁х画涓鐩村埌鏈澶20涓敊璇
路 myisamchk -e -i tbl_name
璞″墠闈㈢殑鍛戒护涓鏍凤紝浣嗘槸-i閫夐」鍛婅瘔myisamchk杩樻墦鍗板嚭涓浜涚粺璁′俊鎭
鍦ㄤ竴鑸娇鐢ㄤ腑锛屼竴涓畝鍗曠殑myisamchk锛堟病鏈夐櫎琛ㄥ悕浠ュ鐨勫弬鏁帮級灏辫冻澶熸鏌ヨ〃浜嗐
鏈妭鎻忚堪濡備綍瀵MyISAM琛ㄤ娇鐢myisamchk(鎵╁睍鍚.MYI鍜.MYD)銆
浣犺繕鍙互(骞朵笖搴旇锛屽鏋滃彲鑳)浣跨敤CHECK TABLE鍜REPAIR TABLE璇彞鏉ユ鏌ュ拰淇MyISAM琛ㄣ傚弬瑙13.5.2.3鑺傦紝鈥淐HECK TABLE璇硶鈥鍜13.5.2.6鑺傦紝鈥淩EPAIR TABLE璇硶鈥銆
涓寮犳崯鍧忕殑琛ㄧ殑鐥囩姸閫氬父鏄煡璇㈡剰澶栦腑鏂苟涓旇兘鐪嬪埌涓嬭堪閿欒锛
瑕佹兂寰楀埌閿欒鐩稿叧鐨勮缁嗕俊鎭紝浣犲彲浠ヨ繍琛perror nnn锛屽叾涓nnn涓洪敊璇紪鍙枫備笅闈㈢殑绀轰緥鏄剧ず浜嗗浣曚娇鐢perror鏉ユ壘鍒版渶甯哥敤閿欒缂栧彿锛堢敤琛ㄧ殑鏂瑰紡鎸囧嚭闂锛夌殑鍚箟锛
shell> perror 126 127 132 134 135 136 141 144 145
126 = Index file is crashed / Wrong file format
127 = Record-file is crashed
132 = Old database file
134 = Record was already deleted (or record file crashed)
135 = No more room in record file
136 = No more room in index file
141 = Duplicate unique key or constraint on write or update
144 = Table is crashed and last repair failed
145 = Table was marked as crashed and should be repaired
璇锋敞鎰忛敊璇135(璁板綍鏂囦欢涓病鏈夋洿澶氱殑绌洪棿)鍜岄敊璇136(绱㈠紩鏂囦欢涓病鏈夋洿澶氱殑绌洪棿)涓嶆槸鍙互閫氳繃绠鍗曚慨澶嶅彲浠ヤ慨澶嶇殑閿欒銆傚湪杩欑鎯呭喌涓嬶紝蹇呴』浣跨敤ALTER TABLE鏉ュ鍔MAX_ROWS鍜AVG_ROW_LENGTH琛ㄩ夐」鍊硷細
ALTER TABLE tbl_name MAX_ROWS=xxx AVG_ROW_LENGTH=yyy;
濡傛灉浣犱笉鐭ラ亾褰撳墠鐨勮〃鐨勯夐」鍊硷紝浣跨敤SHOW CREATE TABLE鎴DESCRIBE鏉ユ煡璇銆
瀵逛簬鍏跺畠鐨勯敊璇紝浣犲繀椤讳慨澶嶈〃銆myisamchk閫氬父鍙互妫娴嬪拰淇澶у鏁伴棶棰樸
淇杩囩▼鍖呮嫭鍥涗釜闃舵锛屾澶勫皢杩涜鎻忚堪銆傚紑濮嬩慨澶嶅墠锛屽簲杩涘叆鏁版嵁搴撶洰褰曞苟妫鏌ヨ〃鏂囦欢鐨勮鍙傚湪Unix涓紝纭繚瀹冧滑瀵逛簬杩愯mysqld鐨鐢ㄦ埛鍙(浣犱篃搴斿彲璇伙紝鍥犱负浣犻渶瑕佽闂鏌ョ殑鏂囦欢)銆傚鏋滀綘闇瑕佷慨鏀规枃浠讹紝浣犺繕蹇呴』鎷ユ湁鍐欒闂潈闄愩
鐢myisamchk淇琛ㄧ殑閫夐」鐨勬弿杩板弬瑙5.9.5鑺傦紝鈥渕yisamchk锛歁yISAM琛ㄧ淮鎶ゅ疄鐢ㄥ伐鍏封鐨勫墠鍑犺妭銆
涓嬮潰鍑犺妭鍒楀嚭浜嗕笂杩板懡浠ゅけ璐ユ垨浣犳兂瑕佷娇鐢myisamchk鎻愪緵鐨勬墿灞曠壒鎬х瓑鎯呭喌鐨勪緥瀛愩
濡傛灉浣犺閫氳繃鍛戒护琛屾潵淇琛紝蹇呴』棣栧厛鍋滄mysqld鏈嶅姟鍣銆傝娉ㄦ剰褰撲綘鍦ㄨ繙绋嬫湇鍔″櫒涓婅繍琛mysqladmin shutdown鏃讹紝mysqladmin杩斿洖鍚庯紝mysqld鏈嶅姟鍣ㄥ皢浠嶇劧杩愯涓浼氬効锛岀洿鍒板仠姝㈡墍鏈夋煡璇㈠苟灏嗘墍鏈夐敭娓呯┖鍒扮‖鐩樹笂銆
闃舵1锛氭鏌ヤ綘鐨勮〃
濡傛灉浣犳湁寰堝鏃堕棿锛岃繍琛myisamchk *.MYI鎴myisamchk -e *.MYI銆備娇鐢-s锛堟矇榛橈級閫夐」绂佹涓嶅繀瑕佺殑淇℃伅銆
濡傛灉mysqld鏈嶅姟鍣ㄥ浜庡畷鏈虹姸鎬锛屽簲浣跨敤--update-state閫夐」鏉ュ憡璇myisamchk灏嗚〃鏍囪涓'妫鏌ヨ繃鐨'銆
浣犲繀椤诲彧淇閭d簺myisamchk鎶ュ憡鏈夐敊璇殑琛ㄣ傚杩欐牱鐨勮〃锛岀户缁埌闃舵2銆
濡傛灉鍦ㄦ鏌ユ椂锛屼綘寰楀埌濂囨殑閿欒(渚嬪out of memory閿欒)锛屾垨濡傛灉myisamchk宕╂簝锛屽埌闃舵3銆
闃舵2锛氱畝鍗曞畨鍏ㄧ殑淇
娉ㄩ噴锛氬鏋滄兂鏇村揩鍦拌繘琛屼慨澶嶏紝褰撹繍琛myisamchk鏃讹紝浣犲簲灏sort_buffer_size鍜Key_buffer_size鍙橀噺鐨勫艰缃负鍙敤鍐呭瓨鐨勫ぇ绾25%銆
棣栧厛锛岃瘯璇myisamchk -r -q tbl_name(-r -q鎰忓懗鐫鈥滃揩閫熸仮澶嶆ā寮忊)銆傝繖灏嗚瘯鍥句笉鎺ヨЕ鏁版嵁鏂囦欢鏉ヤ慨澶嶇储寮曟枃浠躲傚鏋滄暟鎹枃浠跺寘鍚畠搴旀湁鐨勪竴鍒囧唴瀹瑰拰鎸囧悜鏁版嵁鏂囦欢鍐呮纭湴鐐圭殑鍒犻櫎杩炴帴锛岃繖搴旇绠$敤骞朵笖琛ㄥ彲琚慨澶嶃傚紑濮嬩慨澶嶄笅涓寮犺〃銆傚惁鍒欙紝鎵ц涓嬪垪杩囩▼锛
濡傛灉鍦ㄤ慨澶嶆椂锛屼綘寰楀埌濂囨殑閿欒(渚嬪out of memory閿欒)锛屾垨濡傛灉myisamchk宕╂簝锛屽埌闃舵3銆
闃舵3锛氬洶闅剧殑淇
鍙湁鍦ㄧ储寮曟枃浠剁殑绗竴涓16K鍧楄鐮村潖锛屾垨鍖呭惈涓嶆纭殑淇℃伅锛屾垨濡傛灉绱㈠紩鏂囦欢涓㈠け锛屼綘鎵嶅簲璇ュ埌杩欎釜闃舵銆傚湪杩欑鎯呭喌涓嬶紝闇瑕佸垱寤轰竴涓柊鐨勭储寮曟枃浠躲傛寜濡備笅姝ラ鎿嶅仛锛
濡傛灉浣犵殑MySQL鐗堟湰娌℃湁TRUNCATE TABLE锛屽垯浣跨敤DELETE FROM tbl_name銆
鍥炲埌闃舵2銆傜幇鍦myisamchk -r -q搴旇宸ヤ綔浜嗐傦紙杩欎笉搴旇鏄竴涓棤闄愬惊鐜級銆
浣犺繕鍙互浣跨敤REPAIR TABLE tbl_name USE_FRM锛屽皢鑷姩鎵ц鏁翠釜绋嬪簭銆
闃舵4锛氶潪甯稿洶闅剧殑淇
鍙湁.frm鎻忚堪鏂囦欢涔熺牬鍧忎簡锛屼綘鎵嶅簲璇ュ埌杈捐繖涓樁娈点傝繖搴旇浠庢湭鍙戠敓杩囷紝鍥犱负鍦ㄨ〃琚垱寤轰互鍚庯紝鎻忚堪鏂囦欢灏变笉鍐嶆敼鍙樹簡銆
涓轰簡缁勫悎纰庣墖璁板綍骞朵笖娑堥櫎鐢变簬鍒犻櫎鎴栨洿鏂拌褰曡屾氮璐圭殑绌洪棿锛屼互鎭㈠妯″紡杩愯myisamchk锛
shell> myisamchk -r tbl_name
浣犲彲浠ョ敤SQL鐨OPTIMIZE TABLE璇彞浣跨敤鐨勭浉鍚屾柟寮忔潵浼樺寲琛紝OPTIMIZE TABLE鍙互淇琛ㄥ苟瀵归敭鍊艰繘琛屽垎鏋愶紝骞朵笖鍙互瀵圭储寮曟爲杩涜鎺掑簭浠ヤ究鏇村揩鍦版煡鎵鹃敭鍊笺傚疄鐢ㄧ▼搴忓拰鏈嶅姟鍣ㄤ箣闂翠笉鍙兘浜や簰鎿嶄綔锛屽洜涓哄綋浣犱娇鐢OPTIMIZE TABLE鏃讹紝鏈嶅姟鍣ㄥ仛鎵鏈夌殑宸ヤ綔銆傚弬瑙13.5.2.5鑺傦紝鈥淥PTIMIZE TABLE璇硶鈥銆
myisamchk杩樻湁寰堝鍏跺畠鍙敤鏉ユ彁楂樿〃鐨勬ц兘鐨勯夐」锛
路 -S, --sort-index
路 -R index_num, --sort-records=index_num
路 -a, --analyze
鍏充簬杩欎簺閫夐」鐨勫畬鏁寸殑鎻忚堪锛屽弬瑙5.9.5鑺傦紝鈥渕yisamchk锛歁yISAM琛ㄧ淮鎶ゅ疄鐢ㄥ伐鍏封銆
瀹氭湡瀵硅〃杩涜妫鏌ヨ岄潪绛夊埌闂鍑虹幇鍚庡啀妫鏌ユ暟鎹簱琛ㄦ槸涓涓ソ涓绘剰銆傛鏌ュ拰淇MyISAM琛ㄧ殑涓涓柟寮忔槸浣跨敤CHECK TABLE鍜REPAIR TABLE璇彞銆傚弬瑙13.5.2.3鑺傦紝鈥淐HECK TABLE璇硶鈥鍜13.5.2.6鑺傦紝鈥淩EPAIR TABLE璇硶鈥銆
妫鏌ヨ〃鐨勫彟涓涓柟娉曟槸浣跨敤myisamchk銆備负缁存姢鐩殑锛屽彲浠ヤ娇鐢myisamchk -s妫鏌ヨ〃銆-s閫夐」锛堢畝绉--silent锛変娇myisamchk浠ユ矇榛樻ā寮忚繍琛岋紝鍙湁褰撻敊璇嚭鐜版椂鎵嶆墦鍗版秷鎭
鍦ㄦ湇鍔″櫒鍚姩鏃舵鏌ヨ〃鏄竴涓ソ涓绘剰銆備緥濡傦紝鏃犺浣曟椂鏈哄櫒鍦ㄦ洿鏂板綋涓噸鏂板惎鍔ㄤ簡锛屼綘閫氬父闇瑕佹鏌ユ墍鏈夊彲鑳藉彈褰卞搷鐨勮〃銆傦紙鍗斥滈鏈熺殑鐮村潖浜嗙殑琛ㄢ濓級銆傝鎯宠嚜鍔ㄦ鏌MyISAM琛紝鐢--myisam-recover閫夐」鍚姩鏈嶅姟鍣ㄣ
涓涓洿濂界殑娴嬭瘯灏嗘槸妫鏌ユ渶鍚庝慨鏀规椂闂存瘮鈥.pid鈥鏂囦欢鏂扮殑琛ㄣ
浣犺繕搴旇鍦ㄦ甯哥郴缁熸搷浣滄湡闂村畾鏈熸鏌ヨ〃銆傚湪MySQL AB锛屾垜浠繍琛屼竴涓cron浠诲姟锛屾瘡鍛ㄤ竴娆℃鏌ユ墍鏈夐噸瑕佺殑琛紝浣跨敤鈥crontab鈥鏂囦欢涓繖鏍风殑琛岋細
35 0 * * 0 /path/to/myisamchk --fast --silent /path/to/datadir/*/*.MYI
鍙互鎵撳嵃鎹熷潖鐨勮〃鐨勪俊鎭紝浠ヤ究鎴戜滑鍦ㄩ渶瑕佹椂鑳藉妫楠屽苟涓斾慨澶嶅畠浠
澶氬勾浜嗘垜浠繕娌℃湁鍙戠幇(鐨勭‘鏄湡鐨)閮芥病鏈変换浣曟剰澶栨崯鍧忕殑琛ㄦ椂(鐢变簬闄ょ‖浠舵晠闅滃鐨勫叾瀹冨師鍥犻犳垚鎹熷潖鐨勮〃)锛屾瘡鍛ㄤ竴娆″鎴戜滑鏄冻澶熶簡銆
鎴戜滑寤鸿鐜板湪寮濮嬶紝浣犲鎵鏈夋渶鍚24灏忔椂鍐呰鏇存柊浜嗙殑琛ㄦ瘡鏅氶兘鎵цmyisamchk -s锛岀洿鍒颁綘鍙樺緱璞℃垜浠偅鏍蜂俊浠MySQL銆
涓鑸儏鍐碉紝MySQL琛ㄥ緢灏戦渶瑕佺淮鎶ゃ傚鏋滀綘鐢ㄥ姩鎬佸ぇ灏忕殑琛屾洿鏀MyISAM琛(鍚VARCHAR銆BLOB鎴TEXT鍒楃殑琛)鎴栨湁鍒犻櫎浜嗚澶氳鐨勮〃锛屼綘鍙兘鎯宠涓嶆椂鍦帮紙姣忔湀涓娆★級鏁寸悊/缁勫悎琛ㄧ殑绌洪棿銆
鍙互瀵规湁闂鐨勮〃鎵цOPTIMIZE TABLE鏉ヤ紭鍖栥傛垨鑰呮槸锛屽鏋滃彲浠ュ仠涓浼mysqld鏈嶅姟鍣锛岃繘鍏ユ暟鎹洰褰曪紝褰撴湇鍔″櫒鍋滄鏃朵娇鐢ㄨ鍛戒护锛
shell> myisamchk -r -s --sort-index -O sort_buffer_size=16M */*.MYI
涓轰簡鑾峰緱鍏充簬涓涓〃鐨勬弿杩版垨缁熻锛屼娇鐢ㄤ笅闈㈢殑鍛戒护锛
路 myisamchk -d tbl_name
浠モ滄弿杩版ā寮忊濊繍琛myisamchk锛岀敓鎴愯〃鐨勬弿杩般傚鏋滅敤--skip-external-locking閫夐」鍚姩MySQL鏈嶅姟鍣紝myisamchk鍙互鎶ュ憡杩愯鐨勮〃琚洿鏂扮殑閿欒銆傜劧鑰岋紝鏃㈢劧鍦ㄦ弿杩版ā寮忎腑myisamchk涓嶆洿鏀硅〃锛屾病鏈変换浣曠牬鍧忔暟鎹殑椋庨櫓銆
路 myisamchk -d -v tbl_name
涓轰簡鐢熸垚鏇村鍏充簬myisamchk姝e湪鍋氫粈涔堢殑淇℃伅锛屽姞涓-v鍛婅瘔瀹冧互鍐楅暱妯″紡杩愯銆
路 myisamchk -eis tbl_name
浠呮樉绀鸿〃鐨勬渶閲嶈鐨勪俊鎭傚洜涓哄繀椤昏鍙栨暣涓〃锛岃鎿嶄綔寰堟參銆
路 myisamchk -eiv tbl_name
杩欑被浼 -eis锛屽彧鏄憡璇変綘姝e湪鍋氫粈涔堛
涓嬮潰涓鸿繖浜涘懡浠ょ殑杈撳嚭绀轰緥銆傚畠浠熀浜庡惈杩欎簺鏁版嵁鍜岀储寮曟枃浠跺ぇ灏忕殑琛細
-rw-rw-r-- 1 monty tcx 317235748 Jan 12 17:30 company.MYD
-rw-rw-r-- 1 davida tcx 96482304 Jan 12 18:35 company.MYM
myisamchk -d杈撳嚭绀轰緥锛
MyISAM file: company.MYI
Record format: Fixed length
Data records: 1403698 Deleted blocks: 0
Recordlength: 226
table description:
Key Start Len Index Type
1 2 8 unique double
2 15 10 multip. text packed stripped
3 219 8 multip. double
4 63 10 multip. text packed stripped
5 167 2 multip. unsigned short
6 177 4 multip. unsigned long
7 155 4 multip. text
8 138 4 multip. unsigned long
9 177 4 multip. unsigned long
193 1 text
myisamchk -d -v 杈撳嚭绀轰緥锛
MyISAM file: company
Record format: Fixed length
File-version: 1
Creation time: 1999-10-30 12:12:51
Recover time: 1999-10-31 19:13:01
Status: checked
Data records: 1403698 Deleted blocks: 0
Datafile parts: 1403698 Deleted data: 0
Datafile pointer (bytes): 3 Keyfile pointer (bytes): 3
Max datafile length: 3791650815 Max keyfile length: 4294967294
Recordlength: 226
table description:
Key Start Len Index Type Rec/key Root Blocksize
1 2 8 unique double 1 15845376 1024
2 15 10 multip. text packed stripped 2 25062400 1024
3 219 8 multip. double 73 40907776 1024
4 63 10 multip. text packed stripped 5 48097280 1024
5 167 2 multip. unsigned short 4840 55200768 1024
6 177 4 multip. unsigned long 1346 65145856 1024
7 155 4 multip. text 4995 75090944 1024
8 138 4 multip. unsigned long 87 85036032 1024
9 177 4 multip. unsigned long 178 96481280 1024
193 1 text
myisamchk -eis 杈撳嚭绀轰緥锛
Checking MyISAM file: company
Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
Total: Keyblocks used: 98% Packed: 17%
Records: 1403698 M.recordlength: 226
Packed: 0%
Recordspace used: 100% Empty space: 0%
Blocks/Record: 1.00
Record blocks: 1403698 Delete blocks: 0
Recorddata: 317235748 Deleted data: 0
Lost space: 0 Linkdata: 0
User time 1626.51, System time 232.36
Maximum resident set size 0, Integral resident set size 0
Non physical pagefaults 0, Physical pagefaults 627, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 639, Involuntary context switches 28966
myisamchk -eiv 杈撳嚭绀轰緥锛
Checking MyISAM file: company
Data records: 1403698 Deleted blocks: 0
- check file-size
- check delete-chain
block_size 1024:
index 1:
index 2:
index 3:
index 4:
index 5:
index 6:
index 7:
index 8:
index 9:
No recordlinks
- check index reference
- check data record references index: 1
Key: 1: Keyblocks used: 97% Packed: 0% Max levels: 4
- check data record references index: 2
Key: 2: Keyblocks used: 98% Packed: 50% Max levels: 4
- check data record references index: 3
Key: 3: Keyblocks used: 97% Packed: 0% Max levels: 4
- check data record references index: 4
Key: 4: Keyblocks used: 99% Packed: 60% Max levels: 3
- check data record references index: 5
Key: 5: Keyblocks used: 99% Packed: 0% Max levels: 3
- check data record references index: 6
Key: 6: Keyblocks used: 99% Packed: 0% Max levels: 3
- check data record references index: 7
Key: 7: Keyblocks used: 99% Packed: 0% Max levels: 3
- check data record references index: 8
Key: 8: Keyblocks used: 99% Packed: 0% Max levels: 3
- check data record references index: 9
Key: 9: Keyblocks used: 98% Packed: 0% Max levels: 4
Total: Keyblocks used: 9% Packed: 17%
- check records and index references
[LOTS OF ROW NUMBERS DELETED]
Records: 1403698 M.recordlength: 226 Packed: 0%
Recordspace used: 100% Empty space: 0% Blocks/Record: 1.00
Record blocks: 1403698 Delete blocks: 0
Recorddata: 317235748 Deleted data: 0
Lost space: 0 Linkdata: 0
User time 1639.63, System time 251.61
Maximum resident set size 0, Integral resident set size 0
Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0
Blocks in 4 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 10604, Involuntary context switches 122798
涓嬮潰瑙i噴myisamchk浜х敓鐨勪俊鎭殑绫诲瀷銆傗keyfile鈥濇槸绱㈠紩鏂囦欢銆傗滆褰曗濆拰鈥滆鈥濇槸鍚屼箟璇嶃
路 MyISAM file
ISAM(绱㈠紩)鏂囦欢鍚嶃
路 File-version
ISAM鏍煎紡鐨勭増鏈傚綋鍓嶆绘槸2銆
路 Creation time
鏁版嵁鏂囦欢鍒涘缓鐨勬椂闂淬
路 Recover time
绱㈠紩/鏁版嵁鏂囦欢涓婃琚噸寤虹殑鏃堕棿銆
路 Data records
鍦ㄨ〃涓湁澶氬皯璁板綍銆
路 Deleted blocks
鏈夊灏戝垹闄ょ殑鍧椾粛鐒朵繚鐣欑潃绌洪棿銆備綘鍙互浼樺寲琛ㄤ互浣胯繖涓┖闂村噺鍒版渶灏忋傚弬瑙绗7绔狅細浼樺寲銆
路 Datafile parts
瀵瑰姩鎬佽褰曟牸寮忥紝杩欐寚鍑烘湁澶氬皯鏁版嵁鍧椼傚浜庝竴涓病鏈夌鐗囩殑浼樺寲杩囩殑琛紝杩欎笌Data records鐩稿悓銆
路 Deleted data
涓嶈兘鍥炴敹鐨勫垹闄ゆ暟鎹湁澶氬皯瀛楄妭銆備綘鍙互浼樺寲琛ㄤ互浣胯繖涓┖闂村噺鍒版渶灏忋傚弬瑙绗7绔狅細浼樺寲銆
路 Datafile pointer
鏁版嵁鏂囦欢鎸囬拡鐨勫ぇ灏忥紝浠ュ瓧鑺傝銆傚畠閫氬父鏄2銆3銆4鎴5涓瓧鑺傘傚ぇ澶氭暟琛ㄧ敤2涓瓧鑺傜鐞嗭紝浣嗘槸鐩墠杩欒繕涓嶈兘浠MySQL鎺у埗銆傚鍥哄畾琛紝杩欐槸涓涓褰曞湴鍧銆傚鍔ㄦ佽〃锛岃繖鏄竴涓瓧鑺傚湴鍧銆
路 Keyfile pointer
绱㈠紩鏂囦欢鎸囬拡鐨勫ぇ灏忥紝浠ュ瓧鑺傝銆傚畠閫氬父鏄1銆2鎴3涓瓧鑺傘傚ぇ澶氭暟琛ㄧ敤 2 涓瓧鑺傜鐞嗭紝浣嗘槸瀹冭嚜鍔ㄧ敱MySQL璁$畻銆傚畠鎬绘槸涓涓潡鍦板潃銆
路 Max datafile length
琛ㄧ殑鏁版嵁鏂囦欢(.MYD鏂囦欢)鑳藉鏈夊闀匡紝浠ュ瓧鑺傝銆
路 Max keyfile length
琛ㄧ殑閿兼枃浠(.MYI鏂囦欢)鑳藉鏈夊闀匡紝浠ュ瓧鑺傝銆
路 Recordlength
姣忎釜璁板綍鍗犲灏戠┖闂达紝浠ュ瓧鑺傝銆
路 Record format
鐢ㄤ簬瀛樺偍琛ㄨ鐨勬牸寮忋備笂闈㈢殑渚嬪瓙浣跨敤Fixed length銆鍏朵粬鍙兘鐨勫兼槸Compressed鍜Packed銆
路 table description
鍦ㄨ〃涓墍鏈夐敭鍊肩殑鍒楄〃銆傚姣忎釜閿紝缁欏嚭涓浜涘簳灞傜殑淇℃伅锛
o Key
璇ラ敭鐨勭紪鍙枫
o Start
璇ョ储寮曢儴鍒嗕粠璁板綍鐨勫摢閲屽紑濮嬨
o Len
璇ョ储寮曢儴鍒嗘槸澶氶暱銆傚浜庣揣鍑戠殑鏁板瓧锛岃繖搴旇鎬绘槸鍒楃殑鍏ㄩ暱銆傚瀛楃涓诧紝瀹冨彲浠ユ瘮绱㈠紩鐨勫垪鐨勫叏闀跨煭浜涳紝鍥犱负浣犲彲鑳戒細绱㈠紩鍒板瓧绗︿覆鍒楃殑鍓嶇紑銆
o Index
unique鎴multip锛multiple)銆傝〃鏄庝竴涓兼槸鍚﹁兘鍦ㄨ绱㈠紩涓瓨鍦ㄥ娆°
o Type
璇ョ储寮曢儴鍒嗘湁浠涔堟暟鎹被鍨嬨傝繖鏄竴涓packed銆stripped鎴empty閫夐」鐨ISAM鏁版嵁绫诲瀷銆
o Root
鏍圭储寮曞潡鐨勫湴鍧銆
o Blocksize
姣忎釜绱㈠紩鍧楃殑澶у皬銆傞粯璁ゆ槸1024锛屼絾鏄粠婧愮爜鏋勫缓MySQL鏃讹紝璇ュ煎彲浠ュ湪缂栬瘧鏃舵敼鍙樸
o Rec/key
杩欐槸鐢变紭鍖栧櫒浣跨敤鐨勭粺璁″笺傚畠鍛婅瘔瀵硅閿殑姣忎釜鍊兼湁澶氬皯鏉¤褰曘傚敮涓閿绘槸鏈変竴涓1鍊笺傚湪涓涓〃琚杞藉悗(鎴栧彉鏇村緢澶)锛屽彲浠ョ敤myisamchk -a鏇存柊銆傚鏋滄牴鏈病琚洿鏂帮紝缁欏畾涓涓30鐨勯粯璁ゅ笺
鍦ㄤ笂闈緥瀛愮殑琛ㄤ腑锛岀9涓敭鏈変袱涓table description琛屻傝呰鏄庡畠鏄湁2涓儴鍒嗙殑澶氶儴閿
路 Keyblocks used
閿潡浣跨敤鐨勭櫨鍒嗘瘮鏄粈涔堛傚綋鍦ㄤ緥瀛愪腑浣跨敤鐨勮〃鍒氬垰鐢myisamchk閲嶆柊缁勭粐鏃讹紝璇ュ奸潪甯搁珮(寰堟帴杩戠悊璁轰笂鐨勬渶澶у)銆
路 Packed
MySQL璇曞浘鐢ㄤ竴涓氱敤鍚庣紑鍘嬬缉閿傝繖鍙兘琚敤浜CHAR/VARCHAR/DECIMAL鍒楃殑閿傚浜庡乏閮ㄥ垎绫讳技鐨勯暱瀛楃涓诧紝鑳芥樉钁楀湴鍑忓皯浣跨敤绌洪棿銆傚湪涓婇潰鐨勭3涓緥瀛愪腑锛岀4涓敭鏄10涓瓧绗﹂暱锛屽彲浠ュ噺灏60%鐨勭┖闂淬
路 Max levels
瀵逛簬璇ラ敭鐨B鏍戞湁澶氭繁銆傛湁闀块敭鐨勫ぇ琛ㄦ湁杈冮珮鐨勫笺
路 Records
琛ㄤ腑鏈夊灏戣銆
路 M.recordlength
骞冲潎璁板綍闀垮害銆傚浜庢湁瀹氶暱璁板綍鐨勮〃锛岃繖鏄噯纭殑璁板綍闀垮害锛屽洜涓烘墍鏈夎褰曠殑闀垮害鐩稿悓銆
路 Packed
MySQL浠庡瓧绗︿覆鐨勭粨灏惧幓鎺夌┖鏍笺Packed鍊艰〃鏄庤繖鏍峰仛杈惧埌鐨勮妭绾︾殑鐧惧垎姣斻
路 Recordspace used
鏁版嵁鏂囦欢琚娇鐢ㄧ殑鐧惧垎姣斻
路 Empty space
鏁版嵁鏂囦欢鏈浣跨敤鐨勭櫨鍒嗘瘮銆
路 Blocks/Record
姣忎釜璁板綍鐨勫钩鍧囧潡鏁(鍗筹紝涓涓鐗囪褰曠敱澶氬皯涓繛鎺ョ粍鎴)銆傚鍥哄畾鏍煎紡琛紝杩欐绘槸1銆傝鍊煎簲璇ュ敖鍙兘淇濇寔鎺ヨ繎1.0銆傚鏋滃畠鍙樺緱澶ぇ锛屼綘鍙互閲嶆柊缁勭粐琛ㄣ傚弬瑙绗7绔狅細浼樺寲銆
路 Recordblocks
澶氬皯鍧(閾炬帴)琚娇鐢ㄣ傚鍥哄畾鏍煎紡锛屽畠涓庤褰曠殑涓暟鐩稿悓銆
路 Deleteblocks
澶氬皯鍧(閾炬帴)琚垹闄ゃ
路 Recorddata
鍦ㄦ暟鎹枃浠朵腑浣跨敤浜嗗灏戝瓧鑺傘
路 Deleted data
鍦ㄦ暟鎹枃浠朵腑澶氬皯瀛楄妭琚垹闄(鏈娇鐢)銆
路 Lost space
濡傛灉涓涓褰曡鏇存柊涓烘洿鐭殑闀垮害锛屽氨鎹熷け浜嗕竴浜涚┖闂淬傝繖鏄墍鏈夎繖鏍风殑鎹熷け涔嬪拰锛屼互瀛楄妭璁°
路 Linkdata
褰撲娇鐢ㄥ姩鎬佽〃鏍煎紡锛岃褰曠鐗囩敤鎸囬拡杩炴帴(姣忎釜4 锝 7瀛楄妭)銆 Linkdata鎸囪繖鏍风殑鎸囬拡浣跨敤鐨勫唴瀛橀噺涔嬪拰銆
濡傛灉涓寮犺〃宸茬粡鐢myisampack鍘嬬缉浜嗭紝myisamchk -d鎵撳嵃姣忎釜琛ㄥ垪鐨勯檮鍔犱俊鎭傚浜庡畠鐨勪竴涓緥瀛愬強鍏跺惈涔夌殑鎻忚堪锛屽弬瑙8.2鑺傦紝鈥渕yisampack锛氱敓鎴愬帇缂┿佸彧璇籑yISAM琛ㄢ銆
榛樿鎯呭喌涓嬶紝MySQL浣跨敤cp1252(Latin1)瀛楃闆嗘牴鎹Swedish/Finnish瑙勫垯杩涜鎺掑簭銆傝繖浜 榛樿鍊奸傚悎缇庡浗鍜岃タ娆уぇ閮ㄥ垎鍥藉銆
鎵鏈MySQL浜岃繘鍒跺垎鍙戠増鐢--with-extra-charsets=complex缂栬瘧鑰屾垚銆傚彲浠ュ湪鎵鏈夋爣鍑嗙▼搴忎腑娣诲姞浠g爜锛屼娇瀹冧滑鍙互澶勭悊latin1鍜屾墍鏈夊瀛楄妭浜岃繘鍒跺瓧绗﹂泦銆傚叾瀹冨瓧绗﹂泦鏍规嵁闇瑕佷粠瀛楃闆嗗畾涔夋枃浠惰浇鍏ャ
瀛楃闆嗙‘瀹氬湪鍚嶇О涓娇鐢ㄤ粈涔堝瓧绗︺傚畠杩樼‘瀹氬浣曠敤SELECT璇彞鐨ORDER BY鍜GROUP BY瀛愬彞瀵瑰瓧绗︿覆杩涜鎺掑簭銆
杩樺彲浠ュ湪鍚姩鏈嶅姟鍣ㄦ椂鐢--default-character-set閫夐」鏇存敼瀛楃闆嗐傚瓧绗﹂泦鍙互鐢--with-charset=charset鍜--with-extra-charsets=list-of-charsets | complex | all | none閫夐」鏉configure锛屽瓧绗﹂泦閰嶇疆鏂囦欢鍒椾簬SHAREDIR/charsets/Index銆傚弬瑙2.8.2鑺傦紝鈥滃吀鍨嬮厤缃夐」鈥銆
杩樺彲浠ュ湪浣犲惎鍔ㄦ湇鍔″櫒鏃剁敤--default-collation閫夐」鏇存敼瀛楃闆 鏍″瑙勫垯銆傛牎瀵硅鍒欏繀椤绘槸榛樿瀛楃闆嗙殑鍚堟硶鏍″瑙勫垯銆(浣跨敤SHOW COLLATION璇彞鏉ョ‘瀹氭瘡涓瓧绗﹂泦浣跨敤鍝釜鏍″瑙勫垯锛銆 鍙傝2.8.2鑺傦紝鈥滃吀鍨嬮厤缃夐」鈥銆
濡傛灉鍦ㄨ繍琛MySQL鏃舵洿鏀瑰瓧绗﹂泦锛岃繕浼氭洿鏀规帓搴忛『搴忋傜粨鏋滄槸浣犲繀椤诲鎵鏈夎〃杩愯myisamchk -r -q --set-character-set=charset 锛屾垨姝g‘鍦板绱㈠紩杩涜鎺掑簭銆
褰撳鎴风杩炴帴MySQL鏈嶅姟鍣ㄦ椂锛屾湇鍔″櫒鍛婅瘔瀹㈡埛绔湇鍔″櫒鐨勯粯璁ゅ瓧绗﹂泦鏄粈涔堛傚鎴风鍒囨崲鍒拌瀛楃闆嗚繘琛岃繛鎺ャ
褰撹浆涔SQL鏌ヨ鐨勫瓧绗︿覆鏃讹紝浣犲簲浣跨敤mysql_real_escape_string()銆mysql_real_escape_string()绛変环浜庢棫鐨mysql_escape_string()鍑芥暟锛屼笉鍚岀殑鏄畠浣跨敤MYSQL杩炴帴鍙ユ焺浣滀负绗竴涓弬鏁帮紝浠ヤ究杞箟瀛楃鏃跺彲浠ヤ娇鐢ㄧ浉搴旂殑瀛楃闆嗐
濡傛灉瀹㈡埛绔殑缂栬瘧璺緞涓嶆槸鏈嶅姟鍣ㄧ殑瀹夎鐩綍锛屽苟涓旈厤缃MySQL鏃舵病鏈夊寘鎷MySQL浜岃繘鍒朵腑鐨勬墍鏈夊瓧绗﹂泦锛屽鏋滄湇鍔″櫒杩愯鏃堕渶瑕佷娇鐢ㄥ鎴风璁剧疆鐨勫瓧绗﹂泦涔嬪鐨勫叾瀹冨瓧绗﹂泦锛屼綘蹇呴』鍛婅瘔瀹㈡埛绔粠鍝噷鎵惧埌鏇村鐨勫瓧绗﹂泦銆
鍙互鎸囧畾--character-sets-dir閫夐」鏉ヨ〃绀哄姩鎬MySQL瀛楃闆嗘墍淇濆瓨鐩綍鐨勮矾寰勩備緥濡傦紝鍙互灏嗕笅闈㈢殑琛屾斁鍏ラ夐」鏂囦欢涓細
[client]
character-sets-dir=/usr/local/mysql/share/mysql/charsets
浣犲彲浠ュ己鍒跺鎴风浣跨敤涓撶敤瀛楃闆嗭細
[client]
default-character-set=charset
浣嗘槸涓鑸儏鍐典笉闇瑕併
鍦MySQL 5.1涓,鍒嗗埆鎸囧畾瀛楃闆嗗拰 鏍″瑙勫垯銆傝繖璇存槑濡傛灉浣犳兂浣跨敤German鎺掑簭椤哄簭锛屼綘搴旈夋嫨latin1 瀛楃闆嗗拰latin1_german1_ci鎴latin1_german2_ci鏍″瑙勫垯銆備緥濡傦紝瑕佺敤latin1_german1_ci鏍″瑙勫垯鍚姩鏈嶅姟鍣紝搴斾娇鐢--character-set-server=latin1鍜--collation-server=latin1_german1_ci閫夐」銆
鍏充簬杩欎袱绉嶆牎瀵硅鍒欑殑涓嶅悓涔嬪锛屽弬瑙10.10.2鑺傦紝鈥滆タ娆у瓧绗﹂泦鈥銆
瑕佹兂鍦ㄥ惎鍔mysqld鍚庣敤鍏蜂綋璇█鏄剧ず閿欒娑堟伅锛屼娇鐢--language鎴-L閫夐」銆傞夐」鍊煎彲浠ヤ负璇█鍚嶇О鎴栭敊璇秷鎭枃浠剁殑鍏ㄨ矾寰勩備緥濡傦細
shell> mysqld --language=swedish
鎴栵細
shell> mysqld --language=/usr/local/share/swedish
璇█鍚嶅簲涓哄皬鍐欍
璇█鏂囦欢浣嶄簬(榛樿鎯呭喌涓)MySQL鍩烘湰鐩綍鐨share/LANGUAGE鐩綍涓嬨
瑕佹兂鏇存敼閿欒娑堟伅鏂囦欢锛屽簲缂栬緫errmsg.txt鏂囦欢锛岀劧鍚庢墽琛屼笅闈㈢殑鍛戒护浠ョ敓鎴errmsg.sys鏂囦欢锛
shell> comp_err errmsg.txt errmsg.sys
濡傛灉浣犲崌绾у埌鏂扮増鏈殑MySQL锛岃浣忎娇鐢ㄦ柊鐨errmsg.txt鏂囦欢鏉ラ噸鏂版洿鏀广
鏈妭璁ㄨ鍦MySQL涓坊鍔犳柊瀛楃闆嗙殑绋嬪簭銆備綘蹇呴』鏈変竴涓MySQL婧愮爜鍒嗗彂鐗堛
瑕侀夋嫨姝g‘鐨勭▼搴忥紝鍏堢‘瀹氬瓧绗﹂泦鏄畝鍗曞瓧绗﹂泦杩樻槸澶嶆潅瀛楃闆嗭細
路 濡傛灉瀛楃闆嗕笉闇瑕佷娇鐢ㄧ壒娈婂瓧绗︿覆鏍″瑙勫垯绋嬪簭杩涜鎺掑簭锛屽苟涓斾笉闇瑕佸瀛楄妭瀛楃鏀寔锛屽垯涓虹畝鍗曞瓧绗﹂泦銆
路 濡傛灉闇瑕佷笂杩版煇涓壒鎬э紝鍒欎负澶嶆潅瀛楃闆嗐
渚嬪锛latin1鍜danish涓虹畝鍗曞瓧绗﹂泦锛岃big5鍜czech涓哄鏉傚瓧绗﹂泦銆
鍦ㄤ笅闈㈢殑绋嬪簭涓紝瀛楃闆嗗悕鐢MYSET琛ㄧず銆
瀵逛簬绠鍗曞瓧绗﹂泦锛屽簲锛
1. 鍦sql/share/charsets/Index鏂囦欢鏈鍚庢坊鍔MYSET銆傚苟鎸囧畾鍞竴鐨勭紪鍙枫
2. 鍒涘缓鏂囦欢sql/share/charsets/MYSET.conf銆(浣犲彲浠ヤ娇鐢sql/share/charsets/latin1.conf鐨勫浠芥枃浠朵綔涓鸿鏂囦欢鐨勫熀纭锛銆
璇鏂囦欢鐨勮娉曞緢绠鍗曪細
路 娉ㄩ噴浠庘#鈥欏瓧绗﹀紑濮嬶紝涓鐩村埌璇ヨ鏈熬銆
路 鍚勫瓧涔嬮棿鐢ㄤ换鎰忔暟閲忕殑绌烘牸闂撮殧寮銆
路 瀹氫箟瀛楃闆嗘椂锛屾瘡涓瓧蹇呴』涓哄崄鍏繘鍒舵牸寮忕殑鏁板瓧銆
路 ctype鏁扮粍鍗犳嵁鍓257涓瓧銆to_lower[]銆to_upper[]鍜sort_order[]鏁扮粍渚濇鍗犳嵁256涓瓧銆
3. 灏嗗瓧绗﹂泦鍚嶆坊鍔犲埌configurE.in鐨CHARSETS_AVAILABLE鍜COMPILED_CHARSETS鍒椼
4. 閲嶆柊閰嶇疆銆佺紪璇戝苟娴嬭瘯銆
瀵逛簬澶嶆潅瀛楃闆嗭紝搴旓細
1. 鍦MySQL婧愮爜鍒嗗彂鐗堜腑鍒涘缓鏂囦欢strings/ctype-MYSET.c銆
2. 鍦sql/share/charsets/Index鏂囦欢鏈鍚庢坊鍔MYSET銆傚苟鎸囧畾鍞竴鐨勭紪鍙枫
3. 鐪嬬湅宸叉湁鐨ctype-*.c鏂囦欢(渚嬪strings/ctype-big5.c)锛岀湅鐪嬮渶瑕佸畾涔変粈涔堛傝娉ㄦ剰鏂囦欢涓殑鏁扮粍鍚嶅繀椤讳负ctype_MYSET銆to_lower_MYSET绛夌瓑銆傚搴旂畝鍗曞瓧绗﹂泦鐨勬暟缁勩傚弬瑙5.10.4鑺傦紝鈥滃瓧绗﹀畾涔夋暟缁勨銆
4. 鍦ㄦ枃浠堕《閮紝娣诲姞娉ㄩ噴锛
5. /*
6. * This comment is parsed by configure to create ctype.c,
7. * so don't change it unless you know what you are doing.
8. *
9. * .configure. number_MYSET=MYNUMBER
10. * .configure. strxfrm_multiply_MYSET=N
11. * .configure. mbmaxlen_MYSET=N
12. */
configure绋嬪簭浣跨敤璇ユ敞閲婅嚜鍔ㄥ皢瀛楃闆嗗寘鎷繘MySQL搴撲腑銆
鍦ㄤ笅闈㈢珷鑺備腑瑙i噴strxfrm_multiply鍜mbmaxlen 琛屻傚彧鏈夐渶瑕佸瓧绗︿覆姣旇緝鍑芥暟鎴栧瀛楄妭瀛楃闆嗗嚱鏁版椂锛屾墠闇瑕佸崟鐙皢瀹冧滑鍖呮嫭杩涙潵銆
13.鐒跺悗浣犲簲鍒涘缓涓嬮潰鐨勫嚱鏁帮細
14.灏嗗瓧绗﹂泦鍚嶆坊鍔犲埌configurE.in鐨CHARSETS_AVAILABLE鍜COMPILED_CHARSETS鍒椼
15.閲嶆柊閰嶇疆銆佺紪璇戝苟娴嬭瘯銆
sql/share/charsets/README鏂囦欢涓寘鎷缁嗙殑璇存槑銆
濡傛灉浣犳兂瑕MySQL鍒嗗彂涓殑瀛楃闆嗭紝璇峰悜MySQL鍐呴儴閭欢绯荤粺鍙戦偖浠躲傚弬瑙1.7.1.1鑺傦紝鈥淭he MySQL閭欢鍒楄〃鈥銆
to_lower[]鍜to_upper[]鏄畝鍗曟暟缁勶紝鍚湁灏忓啓鍜屽ぇ鍐欏瓧绗︼紝瀵瑰簲瀛楃闆嗙殑姣忎釜鎴愬憳銆備緥濡傦細
to_lower['A'] should contain 'a'
to_upper['a'] should contain 'A'
sort_order[]鏄竴涓槧灏勶紝琛ㄧず濡備綍鎺掑垪瀛楃鐨勯『搴忥紝浠ヤ究杩涜姣旇緝鍜屾帓搴忋傞氬父(浣嗛潪瀵逛簬鎵鏈夊瓧绗﹂泦)涓to_upper[]鐩稿悓锛岃鏄庢帓搴忓澶у皬鍐欐晱鎰熴MySQL鎺掑簭瀛楃鍩轰簬sort_order[]鍏冪礌鐨勫笺傚浜庢洿鍔犲鏉傜殑鎺掑簭瑙勫垯锛屽弬瑙5.10.5鑺傦紝鈥滃瓧绗︿覆姣旇緝鏀寔鈥鐨勫瓧绗︿覆 鏍″瑙勫垯璁ㄨ銆
ctype[]鏄竴涓綅鏁扮粍锛屾瘡涓瓧绗︿负涓涓厓绱犮(璇锋敞鎰忓瓧绗﹀肩储寮to_lower[]銆to_upper[]鍜sort_order[]锛屼絾鐢ㄥ瓧绗﹀+ 1绱㈠紩ctype[]銆傝繖鏄紶缁熺殑杞崲鏂规硶锛岃兘澶熷鐞EOF锛銆
m_ctype.h涓湁涓嬮潰鐨勪綅鎺╃爜瀹氫箟锛
#define _U 01 /* Uppercase */
#define _L 02 /* Lowercase */
#define _N 04 /* Numeral (digit) */
#define _S 010 /* Spacing character */
#define _P 020 /* Punctuation */
#define _C 040 /* Control character */
#define _B 0100 /* Blank */
#define _X 0200 /* heXadecimal digit */
姣忎釜瀛楃鐨ctype[]鏉$洰搴斾负鐩稿簲鐨勬弿杩板瓧绗︾殑浣嶆帺鐮佸肩殑鑱斿悎銆備緥濡傦紝'A'鏄ぇ鍐欏瓧绗(_U)浠ュ強鍗佸叚杩涘埗鏁存暟(_X)锛屽洜姝ctype['A'+1]搴斿寘鍚 鍊硷細
_U + _X = 01 + 0200 = 0201
路 浣犵殑绋嬪簭鐨勫瓧绗﹂泦淇濆瓨璺緞涓嶆纭(榛樿涓/usr/local/mysql/share/mysql/charsets)銆傚彲浠ュ湪杩愯鏈夐棶棰樼殑绋嬪簭鏃堕氳繃--character-sets-dir閫夐」鏉ヤ慨澶嶃
路 瀛楃闆嗕负澶氬瓧鑺傚瓧绗﹂泦锛屼笉鑳藉姩鎬佽浇鍏ャ傚湪杩欑鎯呭喌涓嬶紝浣犲繀椤婚噸鏂扮紪璇戠▼搴忥紝浠ユ敮鎸佸瓧绗﹂泦銆
路 瀛楃闆嗕负鍔ㄦ佸瓧绗﹂泦锛屼絾浣犳病鏈夊搴旂殑閰嶇疆鏂囦欢銆傚湪杩欑鎯呭喌涓嬶紝浣犲簲浠庢柊MySQL鍒嗗彂瀹夎璇ュ瓧绗﹂泦鐨勯厤缃枃浠躲
路 濡傛灉Index鏂囦欢娌℃湁鍖呭惈瀛楃闆嗗悕锛岀▼搴忓皢鏄剧ず涓嬮潰鐨勯敊璇秷鎭細
路 ERROR 1105: File '/usr/local/share/mysql/charsets/?.conf'
路 not found (Errcode锛2)
鍦ㄨ繖绉嶆儏鍐典笅锛屼綘搴旇幏寰楁柊Index鏂囦欢鎴栧湪褰撳墠鏂囦欢涓墜鍔ㄦ坊鍔犲瓧绗﹂泦銆
瀵逛簬MyISAM琛紝鍙互鐢myisamchk -dvv tbl_name妫鏌ヨ〃鐨勫瓧绗﹂泦鍚嶅拰缂栧彿銆
MySQL鏈嶅姟鍣ㄦ湁鍑犱釜鏃跺尯璁剧疆锛
路 绯荤粺鏃跺尯銆傛湇鍔″櫒鍚姩鏃朵究璇曞浘纭畾涓绘満鐨勬椂鍖猴紝鐢ㄥ畠鏉ヨ缃system_time_zone绯荤粺鍙橀噺銆
路 鏈嶅姟鍣ㄥ綋鍓嶇殑鏃跺尯銆傚叏灞绯荤粺鍙橀噺time_zone琛ㄧず鏈嶅姟鍣ㄥ綋鍓嶄娇鐢ㄧ殑鏃跺尯銆傚垵浣垮间负'SYSTEM'锛岃鏄庢湇鍔″櫒鏃跺尯涓庣郴缁熸椂鍖虹浉鍚屻傚彲浠ョ敤--default-time-zone=timez閫夐」鏄惧紡鎸囧畾鍒濅娇鍊笺傚鏋滀綘鏈SUPER 鏉冮檺锛屽彲浠ョ敤涓嬮潰鐨勮鍙ュ湪杩愯鏃惰缃叏灞鍙橀噺鍊硷細
路 mysql> SET GLOBAL time_zone = timezone;
路 姣忎釜杩炴帴鐨勬椂鍖恒傛瘡涓鎴风杩炴帴鏈夎嚜宸辩殑鏃跺尯璁剧疆锛岀敤浼氳瘽time_zone鍙橀噺缁欏嚭銆傚叾鍒濅娇鍊间笌鍏ㄥ眬鍙橀噺time_zone鐩稿悓锛屼絾鍙互鐢ㄤ笅闈㈢殑璇彞閲嶈锛
路 mysql> SET time_zone = timezone;
鍙互鐢ㄤ笅闈㈢殑鏂规硶鏌ヨ褰撳墠鐨勫叏灞鍙橀噺鍊煎拰姣忎釜杩炴帴鐨勬椂鍖猴細
mysql> SELECT @@global.time_zone, @@session.time_zone;
timezone鍊间负瀛楃涓诧紝琛ㄧずUTC鐨勫亸绉婚噺锛屼緥濡'+10:00'鎴'-6:00'銆傚鏋滃凡缁忓垱寤哄苟瑁呭叆mysql鏁版嵁搴撲腑鐨勬椂鍖虹浉鍏宠〃锛屼綘杩樺彲浠ヤ娇鐢ㄥ懡鍚嶇殑鏃跺尯锛屼緥濡'Europe/Helsinki'銆'US/Eastern'鎴'MET'銆傚'SYSTEM'璇存槑璇ユ椂鍖哄簲涓庣郴缁熸椂鍖虹浉鍚屻傛椂鍖哄悕瀵瑰ぇ灏忓啓涓嶆晱鎰熴
MySQL瀹夎绋嬪簭鍦mysql鏁版嵁搴撲腑鍒涘缓鏃跺尯琛紝浣嗕笉瑁呰浇銆備綘蹇呴』鎵嬪姩瑁呰浇銆(濡傛灉浣犳浠庝互鍓嶇殑鐗堟湰鍗囩骇鍒MySQL 4.1.3鎴栨洿鏂扮増鏈紝浣犲簲閫氳繃鍗囩骇mysql鏁版嵁搴撴潵鍒涘缓琛ㄣ傚弬瑙2.10.2鑺傦紝鈥滃崌绾ф巿鏉冭〃鈥涓殑璇存槑锛銆
濡傛灉浣犵殑绯荤粺鏈夎嚜宸辩殑鏃跺尯淇℃伅鏁版嵁搴(鎻忚堪鏃跺尯鐨勪竴绯诲垪鏂囦欢)锛屽簲浣跨敤mysql_tzinfo_to_sql绋嬪簭鏉ュ~鍏呮椂鍖鸿〃銆傜ず渚嬬郴缁熷Linux銆FreeBSD銆Sun Solaris鍜Mac OS X銆傝繖浜涙枃浠剁殑鍙兘浣嶇疆涓/usr/share/zoneinfo鐩綍銆傚鏋滀綘鐨勭郴缁熸病鏈夋椂鍖轰俊鎭暟鎹簱锛屽彲浠ヤ娇鐢ㄦ湰鑺傚悗闈㈡弿杩扮殑涓嬭浇鐨勮蒋浠跺寘銆
mysql_tzinfo_to_sql绋嬪簭鐢ㄦ潵瑁呰浇鏃跺尯琛ㄣ傚湪鍛戒护琛屼腑锛屽皢鏃跺尯淇℃伅鐩綍璺緞鍚嶄紶閫掑埌mysql_tzinfo_to_sql骞惰緭鍑哄彂閫佸埌mysql绋嬪簭銆備緥濡傦細
shell> mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
mysql_tzinfo_to_sql璇诲彇绯荤粺鏃跺尯鏂囦欢骞剁敓鎴SQL璇彞銆mysql澶勭悊杩欎簺璇彞骞惰杞芥椂鍖鸿〃銆
mysql_tzinfo_to_sql杩樺彲浠ョ敤鏉ヨ杞藉崟涓椂鍖烘枃浠讹紝骞剁敓鎴愰棸绉掍俊鎭
瑕佹兂瑁呰浇瀵瑰簲鏃跺尯tz_name鐨勫崟涓椂鍖烘枃浠tz_file锛屽簲杩欐牱璋冪敤mysql_tzinfo_to_sql锛
shell> mysql_tzinfo_to_sql tz_file tz_name | mysql -u root mysql
濡傛灉浣犵殑鏃跺尯闇瑕佽绠楅棸绉掞紝鎸変笅闈㈡柟娉曞垵浣垮寲闂扮淇℃伅锛屽叾涓tz_file鏄椂鍖烘枃浠跺悕锛
shell> mysql_tzinfo_to_sql --leap tz_file | mysql -u root mysql
濡傛灉浣犵殑绯荤粺娌℃湁鏃跺尯淇℃伅鏁版嵁搴 (渚嬪锛Windows鎴HP-UX)锛屼綘鍙互浠http://dev.mysql.com/downloads/timezones.html涓嬭浇棰勬瀯寤烘椂鍖鸿〃杞欢鍖呫傝杞欢鍖呭寘鍚MyISAM鏃跺尯琛ㄦ墍鐢ㄧ殑.frm銆.MYD鍜.MYI鏂囦欢銆傝繖浜涜〃搴斿睘浜mysql鏁版嵁搴擄紝鍥犳搴斿皢杩欎簺鏂囦欢鏀惧埌MySQL鏈嶅姟鍣ㄦ暟鎹洰褰曠殑mysql瀛愮洰褰曘傛搷浣滄椂搴斿叧闂湇鍔″櫒銆
璀﹀憡锛濡傛灉浣犵殑绯荤粺鏈夋椂鍖轰俊鎭暟鎹簱锛岃涓嶈浣跨敤涓嬭浇鐨勮蒋浠跺寘銆傝屽簲浣跨敤mysql_tzinfo_to_sql瀹炵敤宸ュ叿锛佸惁鍒欙紝MySQL鍜岀郴缁熶笂鍏跺畠搴旂敤绋嬪簭澶勭悊鏃ユ湡鏃堕棿鐨勬柟娉曚細鏈夋墍涓嶅悓銆
鍏充簬鍦ㄥ鍒舵椂鏃跺尯璁剧疆鐩稿叧璇锋煡闃6.7鑺傦紝鈥滃鍒剁壒鎬у拰宸茬煡闂鈥銆
MySQL鏈夊嚑涓笉鍚岀殑鏃ュ織鏂囦欢锛屽彲浠ュ府鍔╀綘鎵惧嚭mysqld鍐呴儴鍙戠敓鐨勪簨鎯咃細
鏃ュ織鏂囦欢 |
璁板叆鏂囦欢涓殑淇℃伅绫诲瀷 |
閿欒鏃ュ織 |
璁板綍鍚姩銆佽繍琛屾垨鍋滄mysqld鏃跺嚭鐜扮殑闂銆 |
鏌ヨ鏃ュ織 |
璁板綍寤虹珛鐨勫鎴风杩炴帴鍜屾墽琛岀殑璇彞銆 |
鏇存柊鏃ュ織 |
璁板綍鏇存敼鏁版嵁鐨勮鍙ャ備笉璧炴垚浣跨敤璇ユ棩蹇椼 |
浜岃繘鍒舵棩蹇 |
璁板綍鎵鏈夋洿鏀规暟鎹殑璇彞銆傝繕鐢ㄤ簬澶嶅埗銆 |
鎱㈡棩蹇 |
璁板綍鎵鏈夋墽琛屾椂闂磋秴杩long_query_time绉掔殑鎵鏈夋煡璇㈡垨涓嶄娇鐢ㄧ储寮曠殑鏌ヨ銆 |
榛樿鎯呭喌涓嬶紝鎵鏈夋棩蹇楀垱寤轰簬mysqld鏁版嵁鐩綍涓傞氳繃鍒锋柊鏃ュ織锛屼綘鍙互寮哄埗 mysqld鏉ュ叧闂拰閲嶆柊鎵撳紑鏃ュ織鏂囦欢锛堟垨鑰呭湪鏌愪簺鎯呭喌涓嬪垏鎹㈠埌涓涓柊鐨勬棩蹇楋級銆傚綋浣犳墽琛屼竴涓FLUSH LOGS璇彞鎴栨墽琛mysqladmin flush-logs鎴mysqladmin refresh鏃讹紝鍑虹幇鏃ュ織鍒锋柊銆傚弬瑙13.5.5.2鑺傦紝鈥淔LUSH璇硶鈥銆
濡傛灉浣犳浣跨敤MySQL澶嶅埗鍔熻兘锛屼粠澶嶅埗鏈嶅姟鍣ㄥ皢缁存姢鏇村鏃ュ織鏂囦欢锛岃绉颁负鎺ユ浛鏃ュ織銆傜浉鍏宠璁哄弬瑙绗6绔狅細MySQL涓殑澶嶅埗銆
閿欒鏃ュ織鏂囦欢鍖呭惈浜嗗綋mysqld鍚姩鍜屽仠姝㈡椂锛屼互鍙婃湇鍔″櫒鍦ㄨ繍琛岃繃绋嬩腑鍙戠敓浠讳綍涓ラ噸閿欒鏃剁殑鐩稿叧淇℃伅銆
濡傛灉mysqld鑾悕鍏跺鍦版鎺夊苟涓mysqld_safe闇瑕侀噸鏂板惎鍔ㄥ畠锛mysqld_safe鍦ㄩ敊璇棩蹇椾腑鍐欏叆涓鏉restarted mysqld娑堟伅銆傚鏋mysqld娉ㄦ剰鍒伴渶瑕佽嚜鍔ㄦ鏌ユ垨鐫淇涓涓〃锛屽垯閿欒鏃ュ織涓啓鍏ヤ竴鏉℃秷鎭
鍦ㄤ竴浜涙搷浣滅郴缁熶腑锛屽鏋mysqld姝绘帀锛岄敊璇棩蹇楀寘鍚爢鏍堣窡韪俊鎭傝窡韪俊鎭彲浠ョ敤鏉ョ‘瀹mysqld姝绘帀鐨勫湴鏂广傚弬瑙E.1.4鑺傦紝鈥滀娇鐢ㄥ爢鏍堣窡韪銆
鍙互鐢--log-error[=file_name]閫夐」鏉ユ寚瀹mysqld淇濆瓨閿欒鏃ュ織鏂囦欢鐨勪綅缃傚鏋滄病鏈夌粰瀹file_name鍊硷紝mysqld浣跨敤閿欒鏃ュ織鍚host_name.err 骞跺湪鏁版嵁鐩綍涓啓鍏ユ棩蹇楁枃浠躲傚鏋滀綘鎵цFLUSH LOGS锛岄敊璇棩蹇楃敤-old閲嶆柊鍛藉悕鍚庣紑骞朵笖mysqld鍒涘缓涓涓柊鐨勭┖鏃ュ織鏂囦欢銆(濡傛灉鏈粰鍑--log-error閫夐」锛屽垯涓嶄細閲嶆柊鍛藉悕锛銆
濡傛灉涓嶆寚瀹--log-error锛屾垨鑰(鍦Windows涓)濡傛灉浣犱娇鐢--console閫夐」锛岄敊璇鍐欏叆鏍囧噯閿欒杈撳嚭stderr銆傞氬父鏍囧噯杈撳嚭涓轰綘鐨勭粓绔
鍦Windows涓紝濡傛灉鏈粰鍑--console閫夐」锛岄敊璇緭鍑烘绘槸鍐欏叆.err鏂囦欢銆
mysqld鎸夌収瀹冩帴鏀剁殑椤哄簭璁板綍璇彞鍒版煡璇㈡棩蹇椼傝繖鍙兘涓庢墽琛岀殑椤哄簭涓嶅悓銆傝繖涓庢洿鏂版棩蹇楀拰浜岃繘鍒舵棩蹇椾笉鍚岋紝瀹冧滑鍦ㄦ煡璇㈡墽琛屽悗锛屼絾鏄换浣曚竴涓攣閲婃斁涔嬪墠璁板綍鏃ュ織銆(鏌ヨ鏃ュ織杩樺寘鍚墍鏈夎鍙ワ紝鑰屼簩杩涘埗鏃ュ織涓嶅寘鍚彧鏌ヨ鏁版嵁鐨勮鍙ワ級銆
鏈嶅姟鍣ㄩ噸鏂板惎鍔ㄥ拰鏃ュ織鍒锋柊涓嶄細浜х敓鏂扮殑涓鑸煡璇㈡棩蹇楁枃浠(灏界鍒锋柊鍏抽棴骞堕噸鏂版墦寮涓鑸煡璇㈡棩蹇楁枃浠)銆傚湪Unix涓紝浣犲彲浠ラ氳繃涓嬮潰鐨勫懡浠ら噸鏂板懡鍚嶆枃浠跺苟鍒涘缓涓涓柊鏂囦欢锛
shell> mv hostname.log hostname-old.log
shell> mysqladmin flush-logs
shell> cp hostname-old.log to-backup-directory
shell> rm hostname-old.log
鍦Windows涓紝鏈嶅姟鍣ㄦ墦寮鏃ュ織鏂囦欢鏈熼棿浣犱笉鑳介噸鏂板懡鍚嶆棩蹇楁枃浠躲備綘蹇呴』鍏堝仠姝㈡湇鍔″櫒鐒跺悗閲嶆柊鍛藉悕鏃ュ織鏂囦欢銆傜劧鍚庯紝閲嶅惎鏈嶅姟鍣ㄦ潵鍒涘缓鏂扮殑鏃ュ織鏂囦欢銆
浜岃繘鍒舵棩蹇椾互涓绉嶆洿鏈夋晥鐨勬牸寮忥紝骞朵笖鏄簨鍔″畨鍏ㄧ殑鏂瑰紡鍖呭惈鏇存柊鏃ュ織涓彲鐢ㄧ殑鎵鏈変俊鎭
浜岃繘鍒舵棩蹇楀寘鍚簡鎵鏈夋洿鏂颁簡鏁版嵁鎴栬呭凡缁忔綔鍦ㄦ洿鏂颁簡鏁版嵁锛堜緥濡傦紝娌℃湁鍖归厤浠讳綍琛岀殑涓涓DELETE锛夌殑鎵鏈夎鍙ャ傝鍙ヤ互鈥浜嬩欢鈥濈殑褰㈠紡淇濆瓨锛屽畠鎻忚堪鏁版嵁鏇存敼銆
娉閲婏細浜岃繘鍒舵棩蹇楀凡缁忎唬鏇夸簡鑰佺殑鏇存柊鏃ュ織锛屾洿鏂版棩蹇楀湪MySQL 5.1涓笉鍐嶄娇鐢ㄣ
浜岃繘鍒舵棩蹇楄繕鍖呭惈鍏充簬姣忎釜鏇存柊鏁版嵁搴撶殑璇彞鐨勬墽琛屾椂闂翠俊鎭傚畠涓嶅寘鍚病鏈変慨鏀逛换浣曟暟鎹殑璇彞銆傚鏋滀綘鎯宠璁板綍鎵鏈夎鍙ワ紙渚嬪锛屼负浜嗚瘑鍒湁闂鐨勬煡璇級锛屼綘搴斾娇鐢ㄤ竴鑸煡璇㈡棩蹇椼傚弬瑙5.11.2鑺傦紝鈥滈氱敤鏌ヨ鏃ュ織鈥銆
浜岃繘鍒舵棩蹇楃殑涓昏鐩殑鏄湪鎭㈠浣胯兘澶熸渶澶у彲鑳藉湴鏇存柊鏁版嵁搴擄紝鍥犱负浜岃繘鍒舵棩蹇楀寘鍚浠藉悗杩涜鐨勬墍鏈夋洿鏂般
浜岃繘鍒舵棩蹇楄繕鐢ㄤ簬鍦ㄤ富澶嶅埗鏈嶅姟鍣ㄤ笂璁板綍鎵鏈夊皢鍙戦佺粰浠庢湇鍔″櫒鐨勮鍙ャ傚弬瑙绗6绔狅細MySQL涓殑澶嶅埗銆
杩愯鏈嶅姟鍣ㄦ椂鑻ュ惎鐢ㄤ簩杩涘埗鏃ュ織鍒欐ц兘澶х害鎱1%銆備絾鏄紝浜岃繘鍒舵棩蹇楃殑濂藉锛屽嵆鐢ㄤ簬鎭㈠骞跺厑璁歌缃鍒惰秴杩囦簡杩欎釜灏忓皬鐨勬ц兘鎹熷け銆
褰撶敤--log-bin[=file_name]閫夐」鍚姩鏃讹紝mysqld鍐欏叆鍖呭惈鎵鏈夋洿鏂版暟鎹殑SQL鍛戒护鐨勬棩蹇楁枃浠躲傚鏋滄湭缁欏嚭file_name鍊硷紝 榛樿鍚嶄负-bin鍚庨潰鎵璺熺殑涓绘満鍚嶃傚鏋滅粰鍑轰簡鏂囦欢鍚嶏紝浣嗘病鏈夊寘鍚矾寰勶紝鍒欐枃浠惰鍐欏叆鏁版嵁鐩綍銆傚缓璁寚瀹氫竴涓枃浠跺悕锛屽師鍥犲弬瑙A.8.1鑺傦紝鈥淢ySQL涓殑鎵撳紑浜嬪疁鈥銆
濡傛灉浣犲湪鏃ュ織鍚嶄腑鎻愪緵浜嗘墿灞曞悕(渚嬪锛--log-bin=file_name.extension)锛屽垯鎵╁睍鍚嶈鎮勬倓闄ゆ帀骞跺拷鐣ャ
mysqld鍦ㄦ瘡涓簩杩涘埗鏃ュ織鍚嶅悗闈㈡坊鍔犱竴涓暟瀛楁墿灞曞悕銆傛瘡娆′綘鍚姩鏈嶅姟鍣ㄦ垨鍒锋柊鏃ュ織鏃惰鏁板瓧鍒欏鍔犮傚鏋滃綋鍓嶇殑鏃ュ織澶у皬杈惧埌max_binlog_size锛岃繕浼氳嚜鍔ㄥ垱寤烘柊鐨勪簩杩涘埗鏃ュ織銆傚鏋滀綘姝d娇鐢ㄥぇ鐨勪簨鍔★紝浜岃繘鍒舵棩蹇楄繕浼氳秴杩max_binlog_size锛氫簨鍔″叏鍐欏叆涓涓簩杩涘埗鏃ュ織涓紝缁濆涓嶈鍐欏叆涓嶅悓鐨勪簩杩涘埗鏃ュ織涓
涓轰簡鑳藉鐭ラ亾杩樹娇鐢ㄤ簡鍝釜涓嶅悓鐨勪簩杩涘埗鏃ュ織鏂囦欢锛mysqld杩樺垱寤轰竴涓簩杩涘埗鏃ュ織绱㈠紩鏂囦欢锛屽寘鍚墍鏈変娇鐢ㄧ殑浜岃繘鍒舵棩蹇楁枃浠剁殑鏂囦欢鍚嶃傞粯璁ゆ儏鍐典笅涓庝簩杩涘埗鏃ュ織鏂囦欢鐨勬枃浠跺悕鐩稿悓锛屾墿灞曞悕涓'.index'銆備綘鍙互鐢--log-bin-index[=file_name]閫夐」鏇存敼浜岃繘鍒舵棩蹇楃储寮曟枃浠剁殑鏂囦欢鍚嶃傚綋mysqld鍦ㄨ繍琛屾椂锛屼笉搴旀墜鍔ㄧ紪杈戣鏂囦欢锛涘鏋滆繖鏍峰仛灏嗕細浣mysqld鍙樺緱娣蜂贡銆
鍙互鐢RESET MASTER璇彞鍒犻櫎鎵鏈変簩杩涘埗鏃ュ織鏂囦欢锛屾垨鐢PURGE MASTER LOGS鍙垹闄ら儴鍒嗕簩杩涘埗鏂囦欢銆傚弬瑙13.5.5.5鑺傦紝鈥淩ESET璇硶鈥鍜13.6.1鑺傦紝鈥滅敤浜庢帶鍒朵富鏈嶅姟鍣ㄧ殑SQL璇彞鈥銆
浜岃繘鍒舵棩蹇楁牸寮忔湁涓浜涘凡鐭ラ檺鍒讹紝浼氬奖鍝嶄粠澶囦唤鎭㈠銆傚弬瑙6.7鑺傦紝鈥滃鍒剁壒鎬у拰宸茬煡闂鈥銆
淇濆瓨绋嬪簭鍜岃Е鍙戝櫒鐨勪簩杩涘埗鏃ュ織鐨勬弿杩板弬瑙20.4鑺傦紝鈥滃瓨鍌ㄥ瓙绋嬪簭鍜岃Е鍙戠▼搴忕殑浜岃繘鍒舵棩蹇楀姛鑳解銆
鍙互浣跨敤涓嬮潰鐨mysqld閫夐」鏉ュ奖鍝嶈褰曞埌浜岃繘鍒舵棩蹇楃煡鐨勫唴瀹广傚張瑙侀夐」鍚庨潰鐨勮璁恒
路 --binlog-do-db=db_name
鍛婅瘔涓绘湇鍔″櫒锛屽鏋滃綋鍓嶇殑鏁版嵁搴(鍗USE閫夊畾鐨勬暟鎹簱)鏄db_name锛屽簲灏嗘洿鏂拌褰曞埌浜岃繘鍒舵棩蹇椾腑銆傚叾瀹冩墍鏈夋病鏈夋槑鏄炬寚瀹氱殑鏁版嵁搴 琚拷鐣ャ傚鏋滀娇鐢ㄨ閫夐」锛屼綘搴旂‘淇濆彧瀵瑰綋鍓嶇殑鏁版嵁搴撹繘琛屾洿鏂般
瀵逛簬CREATE DATABASE銆ALTER DATABASE鍜DROP DATABASE璇彞锛屾湁涓涓緥澶栵紝鍗抽氳繃鎿嶄綔鐨勬暟鎹簱鏉ュ喅瀹氭槸鍚﹀簲璁板綍璇彞锛岃屼笉鏄敤褰撳墠鐨勬暟鎹簱銆
涓涓笉鑳芥寜鐓ф湡鏈涙墽琛岀殑渚嬪瓙锛氬鏋滅敤binlog-do-db=sales鍚姩鏈嶅姟鍣紝骞朵笖鎵цUSE prices; UPDATE sales.january SET amount=amount+1000锛锛岃璇彞涓嶅啓鍏ヤ簩杩涘埗鏃ュ織銆
路 --binlog-ignore-db=db_name
鍛婅瘔涓绘湇鍔″櫒锛屽鏋滃綋鍓嶇殑鏁版嵁搴(鍗USE閫夊畾鐨勬暟鎹簱)鏄db_name锛屼笉搴斿皢鏇存柊淇濆瓨鍒颁簩杩涘埗鏃ュ織涓傚鏋滀綘浣跨敤璇ラ夐」锛屼綘搴旂‘淇濆彧瀵瑰綋鍓嶇殑鏁版嵁搴撹繘琛屾洿鏂般
涓涓笉鑳芥寜鐓т綘鏈熸湜鐨勬墽琛岀殑渚嬪瓙锛氬鏋滄湇鍔″櫒鐢binlog-ignore-db=sales鍚姩锛屽苟涓旀墽琛USE prices; UPDATE sales.january SET amount=amount+1000锛锛岃璇彞涓嶅啓鍏ヤ簩杩涘埗鏃ュ織銆
绫讳技浜--binlog-do-db锛屽浜CREATE DATABASE銆ALTER DATABASE鍜DROP DATABASE璇彞锛屾湁涓涓緥澶栵紝鍗抽氳繃鎿嶄綔鐨勬暟鎹簱鏉ュ喅瀹氭槸鍚﹀簲璁板綍璇彞锛岃屼笉鏄敤褰撳墠鐨勬暟鎹簱銆
瑕佹兂璁板綍鎴栧拷瑙嗗涓暟鎹簱锛屼娇鐢ㄥ涓夐」锛屼负姣忎釜鏁版嵁搴撴寚瀹氱浉搴旂殑閫夐」銆
鏈嶅姟鍣ㄦ牴鎹笅闈㈢殑瑙勫垯瀵归夐」杩涜璇勪及锛屼互渚垮皢鏇存柊璁板綍鍒颁簩杩涘埗鏃ュ織涓垨蹇借銆傝娉ㄦ剰瀵逛簬CREATE/ALTER/DROP DATABASE璇彞鏈変竴涓緥澶栥傚湪杩欎簺鎯呭喌涓嬶紝鏍规嵁浠ヤ笅瑙勫垯锛屾墍鍒涘缓銆淇敼鎴栧垹闄ょ殑鏁版嵁搴撳皢浠f浛褰撳墠鐨勬暟鎹簱銆
1. 鏄惁鏈binlog-do-db鎴binlog-ignore-db瑙勫垯?
路 娌℃湁锛氬皢璇彞鍐欏叆浜岃繘鍒舵棩蹇楀苟閫鍑恒
路 鏈夛細鎵ц涓嬩竴姝ャ
2. 鏈変竴浜涜鍒(binlog-do-db鎴binlog-ignore-db鎴栦簩鑰呴兘鏈)銆傚綋鍓嶆湁涓涓暟鎹簱(USE鏄惁閫夋嫨浜嗘暟鎹簱?)?
路 娌℃湁锛涓嶈鍐欏叆璇彞锛屽苟閫鍑恒
路 鏈夛細鎵ц涓嬩竴姝ャ
3. 鏈夊綋鍓嶇殑鏁版嵁搴撱傛槸鍚︽湁binlog-do-db瑙勫垯?
路 鏈夛細褰撳墠鐨勬暟鎹簱鏄惁鍖归厤binlog-do-db瑙勫垯?
o 鏈夛細鍐欏叆璇彞骞堕鍑恒
o 娌℃湁锛氫笉瑕佸啓鍏ヨ鍙ワ紝閫鍑恒
路 No锛氭墽琛屼笅涓姝ャ
4. 鏈変竴浜binlog-ignore-db瑙勫垯銆傚綋鍓嶇殑鏁版嵁搴撴槸鍚﹀尮閰binlog-ignore-db瑙勫垯?
路 鏈夛細涓嶈鍐欏叆璇彞锛屽苟閫鍑恒
路 娌℃湁锛氬啓鍏ユ煡璇㈠苟閫鍑恒
渚嬪锛屽彧鐢binlog-do-db=sales杩愯鐨勬湇鍔″櫒涓嶅皢褰撳墠鏁版嵁搴撲笉涓sales鐨勮鍙ュ啓鍏ヤ簩杩涘埗鏃ュ織(鎹㈠彞璇濊锛binlog-do-db鏈夋椂鍙互琛ㄧず鈥蹇借鍏跺畠鏁版嵁搴鈥)銆
濡傛灉浣犳杩涜澶嶅埗锛屽簲纭繚娌℃湁浠庢湇鍔″櫒鍦ㄤ娇鐢ㄦ棫鐨勪簩杩涘埗鏃ュ織鏂囦欢锛屾柟鍙垹闄ゅ畠浠備竴绉嶆柟娉曟槸姣忓ぉ涓娆℃墽琛mysqladmin flush-logs骞跺垹闄や笁澶╁墠鐨勬墍鏈夋棩蹇椼傚彲浠ユ墜鍔ㄥ垹闄わ紝鎴栨渶濂戒娇鐢PURGE MASTER LOGS(鍙傝13.6.1鑺傦紝鈥滅敤浜庢帶鍒朵富鏈嶅姟鍣ㄧ殑SQL璇彞鈥)锛岃璇彞杩樹細瀹夊叏鍦版洿鏂颁簩杩涘埗鏃ュ織绱㈠紩鏂囦欢(鍙互閲囩敤鏃ユ湡鍙傛暟)銆
鍏锋湁SUPER鏉冮檺鐨勫鎴风鍙互閫氳繃SET SQL_LOG_BIN=0璇彞绂佹灏嗚嚜宸辩殑璇彞璁板叆浜岃繘鍒惰褰曘傚弬瑙13.5.3鑺傦紝鈥淪ET璇硶鈥銆
浣犲彲浠ョ敤mysqlbinlog瀹炵敤宸ュ叿妫鏌ヤ簩杩涘埗鏃ュ織鏂囦欢銆傚鏋滀綘鎯宠閲嶆柊澶勭悊鏃ュ織姝㈢殑璇彞锛岃繖寰堟湁鐢ㄣ備緥濡傦紝鍙互浠庝簩杩涘埗鏃ュ織鏇存柊MySQL鏈嶅姟鍣紝鏂规硶濡備笅锛
shell> mysqlbinlog log-file | mysql -h server_name
鍏充簬mysqlbinlog瀹炵敤宸ュ叿鐨勮缁嗕俊鎭互鍙婂浣曚娇鐢ㄥ畠锛屽弬瑙8.6鑺傦紝鈥渕ysqlbinlog锛氱敤浜庡鐞嗕簩杩涘埗鏃ュ織鏂囦欢鐨勫疄鐢ㄥ伐鍏封銆
濡傛灉浣犳浣跨敤浜嬪姟锛屽繀椤讳娇鐢MySQL浜岃繘鍒舵棩蹇楄繘琛屽浠斤紝鑰屼笉鑳戒娇鐢ㄦ棫鐨勬洿鏂版棩蹇椼
鏌ヨ缁撴潫鍚庛侀攣瀹氳閲婃斁鍓嶆垨鎻愪氦瀹屾垚鍚庡垯绔嬪嵆璁板叆浜岃繘鍒舵棩蹇椼傝繖鏍峰彲浠ョ‘淇濇寜鎵ц椤哄簭璁板叆鏃ュ織銆
瀵归潪浜嬪姟琛ㄧ殑鏇存柊鎵ц瀹屾瘯鍚庣珛鍗充繚瀛樺埌浜岃繘鍒舵棩蹇椾腑銆傚浜庝簨鍔¤〃锛屼緥濡BDB鎴InnoDB琛紝鎵鏈夋洿鏀硅〃鐨勬洿鏂(UPDATE銆DELETE鎴INSERT) 琚紦瀛樿捣鏉ワ紝鐩村埌鏈嶅姟鍣ㄦ帴鏀跺埌COMMIT璇彞銆傚湪璇ョ偣锛屾墽琛屽畬COMMIT涔嬪墠锛mysqld灏嗘暣涓簨鍔″啓鍏ヤ簩杩涘埗鏃ュ織銆傚綋澶勭悊浜嬪姟鐨勭嚎绋嬪惎鍔ㄦ椂锛屽畠涓虹紦鍐叉煡璇㈠垎閰binlog_cache_size澶у皬鐨勫唴瀛樸傚鏋滆鍙ュぇ浜庤鍊硷紝绾跨▼鍒欐墦寮涓存椂鏂囦欢鏉ヤ繚瀛樹簨鍔°傜嚎绋嬬粨鏉熷悗涓存椂鏂囦欢琚垹闄ゃ
Binlog_cache_use鐘舵佸彉閲忔樉绀轰簡浣跨敤璇ョ紦鍐插尯(涔熷彲鑳芥槸涓存椂鏂囦欢)淇濆瓨璇彞鐨勪簨鍔$殑鏁伴噺銆Binlog_cache_disk_use鐘舵佸彉閲忔樉绀轰簡杩欎簺浜嬪姟涓疄闄呬笂鏈夊灏戝繀椤讳娇鐢ㄤ复鏃舵枃浠躲傝繖涓や釜鍙橀噺鍙互鐢ㄤ簬灏binlog_cache_size璋冭妭鍒拌冻澶熷ぇ鐨勫硷紝浠ラ伩鍏嶄娇鐢ㄤ复鏃舵枃浠躲
max_binlog_cache_size(榛樿4GB)鍙互鐢ㄦ潵闄愬埗鐢ㄦ潵缂撳瓨澶氳鍙ヤ簨鍔$殑缂撳啿鍖烘诲ぇ灏忋傚鏋滄煇涓簨鍔″ぇ浜庤鍊硷紝灏嗕細澶辫触骞 鍥炴粴銆
濡傛灉浣犳浣跨敤鏇存柊鏃ュ織鎴栦簩杩涘埗鏃ュ織锛屽綋浣跨敤CREATE ... SELECT or INSERT ... SELECT鏃讹紝骞惰鎻掑叆琚浆鎹负鏅氭彃鍏ャ傝繖鏍烽氳繃鍦ㄥ浠芥椂浣跨敤鏃ュ織鍙互纭繚閲嶆柊鍒涘缓琛ㄧ殑澶囦唤銆
璇锋敞鎰MySQL 5.1鍊肩殑浜岃繘鍒舵棩蹇楁牸寮忎笌浠ュ墠鐗堟湰鐨MySQL涓嶅悓锛屽洜涓哄鍒舵敼杩涗簡銆傚弬瑙6.5鑺傦紝鈥滀笉鍚孧ySQL鐗堟湰涔嬮棿鐨勫鍒跺吋瀹规р銆
榛樿鎯呭喌涓嬶紝骞朵笉鏄瘡娆″啓鍏ユ椂閮藉皢浜岃繘鍒舵棩蹇椾笌纭洏鍚屾銆傚洜姝ゅ鏋滄搷浣滅郴缁熸垨鏈哄櫒(涓嶄粎浠呮槸MySQL鏈嶅姟鍣)宕╂簝锛屾湁鍙兘浜岃繘鍒舵棩蹇椾腑鏈鍚庣殑璇彞涓㈠け浜嗐傝鎯抽槻姝㈣繖绉嶆儏鍐碉紝浣犲彲浠ヤ娇鐢sync_binlog鍏ㄥ眬鍙橀噺(1鏄渶瀹夊叏鐨勫硷紝浣嗕篃鏄渶鎱㈢殑)锛屼娇浜岃繘鍒舵棩蹇楀湪姣N娆′簩杩涘埗鏃ュ織鍐欏叆鍚庝笌纭洏鍚屾銆傚弬瑙5.3.3鑺傦紝鈥滄湇鍔″櫒绯荤粺鍙橀噺鈥銆傚嵆浣sync_binlog璁剧疆涓1,鍑虹幇宕╂簝鏃讹紝涔熸湁鍙兘琛ㄥ唴瀹瑰拰浜岃繘鍒舵棩蹇楀唴瀹逛箣闂村瓨鍦ㄤ笉涓鑷存с備緥濡傦紝濡傛灉浣跨敤InnoDB琛紝MySQL鏈嶅姟鍣ㄥ鐞COMMIT璇彞锛屽畠灏嗘暣涓簨鍔″啓鍏ヤ簩杩涘埗鏃ュ織骞跺皢浜嬪姟鎻愪氦鍒InnoDB涓銆濡傛灉鍦ㄤ袱娆℃搷浣滀箣闂村嚭鐜板穿婧冿紝閲嶅惎鏃讹紝浜嬪姟琚InnoDB鍥炴粴锛屼絾浠嶇劧瀛樺湪浜岃繘鍒舵棩蹇椾腑銆傚彲浠ョ敤--innodb-safe-binlog閫夐」瑙e喅璇ラ棶棰橈紝鍙互澧炲姞InnoDB琛ㄥ唴瀹瑰拰浜岃繘鍒舵棩蹇椾箣闂寸殑涓鑷存с(娉ㄩ噴锛氬湪MySQL 5.1涓笉闇瑕--innodb-safe-binlog锛涚敱浜庡紩鍏ヤ簡XA浜嬪姟鏀寔锛岃閫夐」浣滃簾浜嗭級銆
璇ラ夐」鍙互鎻愪緵鏇村ぇ绋嬪害鐨勫畨鍏紝杩樺簲瀵MySQL鏈嶅姟鍣ㄨ繘琛岄厤缃紝浣挎瘡涓簨鍔$殑浜岃繘鍒舵棩蹇(sync_binlog =1)鍜(榛樿鎯呭喌涓虹湡)InnoDB鏃ュ織涓庣‖鐩樺悓姝ャ傝閫夐」鐨勬晥鏋滄槸宕╂簝鍚庨噸鍚椂锛屽湪婊氬洖浜嬪姟鍚庯紝MySQL鏈嶅姟鍣ㄤ粠浜岃繘鍒舵棩蹇楀壀鍒 鍥炴粴鐨InnoDB浜嬪姟銆傝繖鏍峰彲浠ョ‘淇濅簩杩涘埗鏃ュ織鍙嶉InnoDB琛ㄧ殑纭垏鏁版嵁绛夛紝骞朵娇浠庢湇鍔″櫒淇濇寔涓庝富鏈嶅姟鍣ㄤ繚鎸佸悓姝(涓嶆帴鏀 鍥炴粴鐨勮鍙)銆
璇锋敞鎰忓嵆浣MySQL鏈嶅姟鍣ㄦ洿鏂板叾瀹冨瓨鍌ㄥ紩鎿庤屼笉鏄InnoDB锛屼篃鍙互浣跨敤--innodb-safe-binlog銆傚湪InnoDB宕╂簝鎭㈠鏃讹紝鍙粠浜岃繘鍒舵棩蹇椾腑鍒犻櫎褰卞搷InnoDB琛ㄧ殑璇彞/浜嬪姟銆傚鏋滃穿婧冩仮澶嶆椂MySQL鏈嶅姟鍣ㄥ彂鐜颁簩杩涘埗鏃ュ織鍙樼煭浜(鍗宠嚦灏戠己灏戜竴涓垚鍔熸彁浜ょ殑InnoDB浜嬪姟)锛屽鏋sync_binlog =1骞朵笖纭洏/鏂囦欢绯荤粺鐨勭‘鑳芥牴鎹渶瑕佽繘琛屽悓姝(鏈変簺涓嶉渶瑕)鍒欎笉浼氬彂鐢燂紝鍒欒緭鍑洪敊璇秷鎭 ("浜岃繘鍒舵棩蹇<鍚>姣旀湡鏈涚殑瑕佸皬")銆傚湪杩欑鎯呭喌涓嬶紝浜岃繘鍒舵棩蹇椾笉鍑嗙‘锛屽鍒跺簲浠庝富鏈嶅姟鍣ㄧ殑鏁版嵁蹇収寮濮嬨
鍐欏叆浜岃繘鍒舵棩蹇楁枃浠跺拰浜岃繘鍒舵棩蹇楃储寮曟枃浠剁殑鏂规硶涓庡啓鍏MyISAM琛ㄧ浉鍚屻傚弬瑙A.4.3鑺傦紝鈥淢ySQL澶勭悊纾佺洏婊$殑鏂瑰紡鈥銆
鐢--log-slow-queries[=file_name]閫夐」鍚姩鏃讹紝mysqld鍐欎竴涓寘鍚墍鏈夋墽琛屾椂闂磋秴杩long_query_time绉掔殑SQL璇彞鐨勬棩蹇楁枃浠躲傝幏寰楀垵浣胯〃閿佸畾鐨勬椂闂翠笉绠椾綔鎵ц鏃堕棿銆
濡傛灉娌℃湁缁欏嚭file_name鍊硷紝 榛樿鏈富鏈哄悕锛屽悗缂涓-slow.log銆傚鏋滅粰鍑轰簡鏂囦欢鍚嶏紝浣嗕笉鏄粷瀵硅矾寰勫悕锛屾枃浠跺垯鍐欏叆鏁版嵁鐩綍銆
璇彞鎵ц瀹屽苟涓旀墍鏈夐攣閲婃斁鍚庤鍏ユ參鏌ヨ鏃ュ織銆傝褰曢『搴忓彲浠ヤ笌鎵ц椤哄簭涓嶇浉鍚屻
鎱㈡煡璇㈡棩蹇楀彲浠ョ敤鏉ユ壘鍒版墽琛屾椂闂撮暱鐨勬煡璇紝鍙互鐢ㄤ簬浼樺寲銆備絾鏄紝妫鏌ュ張闀垮張鎱㈢殑鏌ヨ鏃ュ織浼氬緢鍥伴毦銆傝鎯冲鏄撲簺锛屼綘鍙互浣跨敤mysqldumpslow鍛戒护鑾峰緱鏃ュ織涓樉绀虹殑鏌ヨ鎽樿鏉ュ鐞嗘參鏌ヨ鏃ュ織銆
鍦MySQL 5.1鐨勬參鏌ヨ鏃ュ織涓紝涓嶄娇鐢ㄧ储寮曠殑鎱㈡煡璇㈠悓浣跨敤绱㈠紩鐨勬煡璇竴鏍疯褰曘傝鎯抽槻姝笉浣跨敤绱㈠紩鐨勬參鏌ヨ璁板叆鎱㈡煡璇㈡棩蹇楋紝浣跨敤--log-short-format閫夐」銆傚弬瑙5.3.1鑺傦紝鈥mysqld鍛戒护琛岄夐」鈥銆
鍦MySQL 5.1涓,閫氳繃--log-slow-admin-statements鏈嶅姟鍣ㄩ夐」锛屼綘鍙互璇锋眰灏嗘參绠$悊璇彞锛屼緥濡OPTIMIZE TABLE銆ANALYZE TABLE鍜 ALTER TABLE鍐欏叆鎱㈡煡璇㈡棩蹇椼
鐢ㄦ煡璇㈢紦瀛樺鐞嗙殑鏌ヨ涓嶅姞鍒版參鏌ヨ鏃ュ織涓紝鍥犱负琛ㄦ湁闆惰鎴栦竴琛岃屼笉鑳戒粠绱㈠紩涓彈鐩婄殑鏌ヨ涔熶笉鍐欏叆鎱㈡煡璇㈡棩蹇椼
MySQL鏈嶅姟鍣ㄥ彲浠ュ垱寤哄悇绉嶄笉鍚岀殑鏃ュ織鏂囦欢锛屼粠鑰屽彲浠ュ緢瀹规槗鍦扮湅瑙佹墍杩涜鐨勬搷浣溿傚弬瑙5.11鑺傦紝鈥淢ySQL鏃ュ織鏂囦欢鈥銆備絾鏄紝浣犲繀椤诲畾鏈熸竻鐞嗚繖浜涙枃浠讹紝纭繚鏃ュ織涓嶄細鍗犵敤澶鐨勭‖鐩樼┖闂淬
褰撳惎鐢ㄦ棩蹇椾娇鐢MySQL鏃讹紝浣犲彲鑳芥兂瑕佷笉鏃跺湴澶囦唤骞跺垹闄ゆ棫鐨勬棩蹇楁枃浠讹紝骞跺憡璇MySQL寮濮嬭鍏ユ柊鏂囦欢銆傚弬瑙5.9.1鑺傦紝鈥滄暟鎹簱澶囦唤鈥銆
鍦 Linux (Redhat)鐨勫畨瑁呬笂锛屼綘鍙负姝や娇鐢mysql-log-rotate鑴氭湰銆傚鏋滀綘浠RPM鍒嗗彂瀹夎MySQL锛岃剼鏈簲璇ヨ嚜鍔ㄨ瀹夎浜嗐
鍦ㄥ叾瀹冪郴缁熶笂锛屼綘蹇呴』鑷繁瀹夎鐭剼鏈紝浣犲彲浠cron绛夊叆鎵嬪鐞嗘棩蹇楁枃浠躲
浣犲彲浠ラ氳繃mysqladmin flush-logs鎴SQL璇彞FLUSH LOGS鏉ュ己鍒MySQL寮濮嬩娇鐢ㄦ柊鐨勬棩蹇楁枃浠躲
鏃ュ織娓呯┖鎿嶄綔鍋氫笅鍒椾簨鎯咃細
濡傛灉浣犲彧浣跨敤鏇存柊鏃ュ織锛屼綘鍙渶瑕侀噸鏂板懡鍚嶆棩蹇楁枃浠讹紝鐒跺悗鍦ㄥ浠藉墠娓呯┖鏃ュ織銆備緥濡傦紝浣犲彲浠ヨ繖鏍峰仛锛
shell> cd mysql-data-directory
shell> mv mysql.log mysql.old
shell> mysqladmin flush-logs
鐒跺悗鍋氬浠藉苟鍒犻櫎鈥mysql.old鈥銆
鍦ㄤ竴浜涙儏鍐典笅锛屼綘鍙兘鎯宠鍦ㄥ悓涓鍙版満鍣ㄤ笂杩愯澶氫釜mysqld鏈嶅姟鍣銆備綘鍙兘鎯宠娴嬭瘯涓涓柊鐨MySQL鍙戝竷锛屽悓鏃朵笉褰卞搷鐜版湁浜у搧鐨勮缃傛垨鑰咃紝浣犲彲鑳芥兂浣夸笉鍚岀殑鐢ㄦ埛璁块棶鏉ヨ闂笉鍚岀殑mysqld鏈嶅姟鍣浠ヤ究浠栦滑鑷繁鏉ョ鐞嗐(渚嬪锛屼綘鍙兘鏄竴涓Internet鏈嶅姟鎻愪緵鍟嗭紝甯屾湜涓轰笉鍚岀殑瀹㈡埛鏉ユ彁渚涚嫭绔嬬殑MySQL瀹夎锛銆
瑕佹兂鍦ㄤ竴涓崟鐙殑鏈哄櫒涓婅繍琛屽涓湇鍔″櫒锛屾瘡涓湇鍔″櫒蹇呴』鏈夊敮涓鐨勫悇杩愯鍙傛暟鍊笺傝繖浜涘煎彲浠ュ湪鍛戒护琛屼腑璁剧疆鎴栧湪閫夐」鏂囦欢涓缃傚弬瑙4.3鑺傦紝鈥滄寚瀹氱▼搴忛夐」鈥銆
鑷冲皯涓嬮潰鐨勯夐」瀵规瘡涓湇鍔″櫒蹇呴』鏄笉鍚岀殑锛
路 --port=port_num
--port鎺у埗鐫TCP/IP杩炴帴鐨勭鍙e彿銆
路 --socket=path
--socket鎺у埗Unix涓殑Unix濂楁帴瀛楁枃浠惰矾寰勫拰鍦Windows涓殑鍛藉悕绠¢亾鍚嶇О銆傚湪Windows涓紝鍙湁鏀寔鍛藉悕绠¢亾杩炴帴鐨勬湇鍔″櫒鎵嶉渶瑕佹槑纭寚瀹氱閬撳悕绉般
路 --shared-memory-base-name=name
璇ラ夐」褰撳墠鍙湪Windows涓娇鐢ㄣ傚畠鎸囧畾Windows鏈嶅姟鍣ㄤ娇鐢ㄧ殑銆佸厑璁稿鎴风閫氳繃鍏变韩鍐呭瓨鏉ヨ繛鎺ョ殑鍏变韩鍐呭瓨鍚嶃
路 --pid-file=path
璇ラ夐」鍙湪Unix涓娇鐢ㄣ傚畠鎸囧嚭鏈嶅姟鍣ㄥ湪鍏朵腑鍐欏叆杩涚▼ID鐨勬枃浠跺悕銆
濡傛灉浣犱娇鐢ㄤ笅闈㈢殑鏃ュ織鏂囦欢閫夐」锛屽浜庢瘡涓湇鍔″櫒鏉ヨ锛屽畠浠繀椤绘槸涓嶅悓鐨勶細
路 --log=path
路 --log-bin=path
路 --log-update=path
路 --log-error=path
路 --bdb-logdir=path
鏃ュ織鏂囦欢閫夐」鐨勬弿杩板弬瑙5.11.5鑺傦紝鈥滄棩蹇楁枃浠剁淮鎶も銆
涓轰簡鎻愰珮鎬ц兘锛屼綘鍙互涓烘瘡涓湇鍔″櫒鎸囧畾涓嬮潰閫夐」鐨勪笉鍚岀殑鍊硷紝浠ヤ究鍦ㄧ墿鐞嗙鐩樹箣闂村钩鍧囧垎閰嶈礋鑽凤細
路 --tmpdir=path
路 --bdb-tmpdir=path
杩樻帹鑽愪娇鐢ㄤ笉鍚岀殑涓存椂鐩綍锛屼互渚垮鏄撳湴纭畾鍝釜MySQL鏈嶅姟鍣ㄥ垱寤轰簡缁欏畾鐨勪复鏃舵枃浠躲
涓鑸儏鍐碉紝姣忎釜鏈嶅姟鍣ㄥ簲杩樹娇鐢ㄤ笉鍚岀殑鏁版嵁鐩綍锛屽彲浠ラ氳繃--datadir=path閫夐」鏉ユ寚瀹氥
璀﹀憡锛涓鑸儏鍐碉紝浣犲喅涓嶈璁╀袱涓湇鍔″櫒鏇存柊鐩稿悓鏁版嵁搴撲腑鐨勬暟鎹傚惁鍒欙紝濡傛灉浣犵殑鎿嶄綔绯荤粺涓嶆敮鎸佹晠闅滄帓闄ょ郴缁熼攣瀹氾紝璇ュ彲鑳戒細瀵艰嚧闈炲父濂囨殑缁撴灉銆傚鏋滐紙涓嶇悊浼氳璀﹀憡锛夎繍琛岀殑澶氫釜鏈嶅姟鍣ㄤ娇鐢ㄧ浉鍚岀殑鏁版嵁鐩綍骞朵笖鍚敤浜嗘棩蹇楄褰曪紝浣犲繀椤讳娇鐢ㄩ傚綋鐨勯夐」鏉ヤ负姣忎釜鏈嶅姟鍣ㄦ寚瀹氬敮涓鐨勬棩蹇楁枃浠跺悕銆傚惁鍒欙紝鏈嶅姟鍣ㄥ皾璇曠敤鐩稿悓鐨勬枃浠舵潵璁板綍鏃ュ織銆傝娉ㄦ剰杩欑绫诲瀷鐨勮缃彧鑳藉湪MyISAM鍜MERGE琛ㄤ笂宸ヤ綔锛屽鍏跺畠浠讳綍瀛樺偍寮曟搸涓嶈捣浣滅敤銆
澶氫釜鏈嶅姟鍣ㄥ叡浜竴涓暟鎹洰褰曠殑璀﹀憡涔熼傜敤浜NFS鐜銆傚厑璁稿涓MySQL鏈嶅姟鍣ㄩ氳繃NFS璁块棶涓涓叡鍚岀殑鏁版嵁鐩綍鏄竴涓闈炲父涓嶅ソ鐨勪富涔銆
路 涓昏闂鏄NFS瀛樺湪閫熷害鐡堕銆傚畠涓嶆槸鐢ㄤ簬杩欑鐢ㄩ斻
路 鐢NFS鐨勫彟涓涓啋闄╂槸浣犲繀椤绘彁鍑轰竴涓柟娉曟潵纭繚涓や釜鎴栧涓湇鍔″櫒涓嶄細鐩镐簰骞叉壈銆NFS鏂囦欢鐨勯攣瀹氶氬父鐢lockd鍚庡彴绋嬪簭澶勭悊锛屼絾鏄洰鍓嶏紝娌℃湁涓涓繍琛屽钩鍙拌兘澶熷湪姣忕鎯呭喌涓100%鍙潬鍦拌繘琛岄攣瀹氥
浣夸綘鏇村姞瀹规槗锛氬繕璁板湪鏈嶅姟鍣ㄤ箣闂撮氳繃NFS鍏变韩鏁版嵁鐩綍銆備竴涓緝濂界殑瑙e喅鏂规鏄娇鐢ㄥ寘鍚嚑涓CPU骞朵笖鍜屼娇鐢ㄦ湁鏁堝鐞嗗绾跨▼鐨勬搷浣滅郴缁熺殑鏈哄櫒銆
濡傛灉鍦ㄤ笉鍚岀殑浣嶇疆鏈夊涓MySQL鐨勫畨瑁咃紝涓鑸儏鍐靛彲浠ョ敤--basedir=path閫夐」涓烘瘡涓湇鍔″櫒鎸囧畾鍩烘湰瀹夎鐩綍锛屼娇姣忎釜鏈嶅姟鍣ㄤ娇鐢ㄤ笉鍚岀殑鏁版嵁鐩綍銆佹棩蹇楁枃浠跺拰PID鏂囦欢銆傦紙鎵鏈夎繖浜涘肩殑 榛樿鍊肩浉瀵逛簬鏍圭洰褰曟潵纭畾锛夈傞偅鏍风殑璇濓紝 浣犲敮涓闇瑕佹寚瀹氱殑鍏跺畠閫夐」鏄--socket鍜--port閫夐」銆備緥濡傦紝鍋囧浣跨敤tar鏂囦欢浜岃繘鍒跺垎鍙戠増瀹夎涓嶅悓鐨MySQL鐗堟湰銆傝繖浜涘畨瑁呭湪涓嶅悓鐨勪綅缃紝鍥犳鍙互浣跨敤鍚勪釜瀹夎鏈嶅姟鍣ㄧ浉搴旂殑鏍圭洰褰曚腑鐨bin/mysqld_safe鍛戒护鏉鍚姩鏈嶅姟鍣ㄣmysqld_safe纭畾姝g‘鐨--basedir閫夐」浼犻掔粰mysqld锛屼綘浠呴渶瑕佷负mysqld_safe鎸囧畾--socket鍜--port閫夐」銆
姝e涓嬮潰鍑犺妭鎵璁ㄨ鐨勯偅鏍凤紝鍙互閫氳繃璁剧疆鐜鍙橀噺鎴栫敤鎸囧畾鐨勫懡浠よ閫夐」鏉ュ惎鍔ㄦ洿澶氱殑鏈嶅姟鍣ㄣ備絾鏄紝濡傛灉浣犻渶瑕佸湪涓涓洿绋冲畾鐨勫熀纭涓婅繍琛屽涓湇鍔″櫒锛屼竴涓洿鏂逛究鐨勬柟娉曟槸浣跨敤閫夐」鏂囦欢鏉ヤ负姣忎釜鏈嶅姟鍣ㄦ寚瀹氶偅浜涢夐」鍊硷紝瀹冨姣忎釜鏈嶅姟鍣ㄥ繀椤绘槸鍞竴鐨勩
鍦Windows涓紝鍙互浠庡懡浠よ鎵嬪姩鍚姩鏉ヨ繍琛屽涓湇鍔″櫒锛屾瘡涓湇鍔″櫒浣跨敤鍚堥傜殑鎿嶄綔鍙傛暟銆傚湪鍩轰簬Windows NT鐨勭郴缁熶腑锛屽畨瑁呭嚑涓湇鍔″櫒鏃讹紝浣犺繕鏈夊皢澶氫釜鏈嶅姟鍣ㄥ畨瑁呬负Windows鏈嶅姟骞惰繍琛岀殑閫夐」銆傚叧浜庝粠鍛戒护琛岃繍琛MySQL鏈嶅姟鍣ㄦ垨浣滀负鏈嶅姟杩愯鐨勪竴鑸鏄庡湪 2.3鑺傦紝鈥滃湪Windows涓婂畨瑁匨ySQL鈥涓粰鍑恒傛湰鑺傛弿杩版庢牱纭繚浣犵敤涓嶅悓鐨勫惎鍔ㄩ夐」鍊硷紙瀵逛簬姣忎釜鏈嶅姟鍣ㄥ繀椤绘槸鍞竴鐨勶紝渚嬪鏁版嵁鐩綍锛夊惎鍔ㄥ悇涓湇鍔″櫒銆傝繖浜涢夐」鐨勬弿杩拌5.12鑺傦紝鈥滃湪鍚屼竴鍙版満鍣ㄤ笂杩愯澶氫釜MySQL鏈嶅姟鍣ㄢ銆
鍋囪浣犳兂瑕佸湪绔彛3307浣跨敤鏁版嵁鐩綍C:\mydata1杩愯mysqld锛屽苟涓旀兂鍦ㄧ鍙3308浣跨敤鏁版嵁鐩綍C:\mydata1杩愯mysqld-max銆(瑕佹兂杩欐牱鍋氾紝鍚姩鏈嶅姟鍣ㄤ箣鍓嶈纭繚锛屾瘡涓暟鎹洰褰曞瓨鍦ㄥ苟涓旀湁鑷繁鐨mysql鏁版嵁搴撴嫹璐濓紝瀹冨寘鍚 鎺堟潈琛級銆
鐒跺悗鍒涘缓涓や釜閫夐」鏂囦欢銆備緥濡傦紝鍒涘缓涓涓枃浠跺悕涓C:\my-opts1.cnf鐨勯厤缃枃浠讹紝瀹冪湅璧锋潵璞¤繖涓牱瀛愶細
[mysqld]
datadir = C:/mydata1
port = 3307
鍒涘缓绗簩涓枃浠跺悕涓C:\my-opts1.cnf鐨勯厤缃枃浠讹紝瀹冪湅璧锋潵璞¤繖涓牱瀛愶細
mysqld]
datadir = C:/mydata2
port = 3308
鐒跺悗锛岀敤瀹冧滑鑷繁鐨勯夐」鏂囦欢鍚姩姣忎釜鏈嶅姟鍣細
C:\> C:\mysql\bin\mysqld --defaults-file=C:\my-opts1.cnf
C:\> C:\mysql\bin\mysqld-max --defaults-file=C:\my-opts2.cnf
鍦NT涓紝姣忎釜鏈嶅姟鍣ㄥ湪鍓嶅彴鍚姩锛堟湇鍔″櫒閫鍑哄墠锛屼笉浼氭樉绀烘柊鐨勬彁绀虹锛夛紱闇瑕佸湪涓や釜鎺у埗鍙扮獥鍙d腑鎵ц杩欎袱涓懡浠ゃ
瑕佹兂鍏抽棴鏈嶅姟鍣紝蹇呴』杩炴帴鍒扮浉搴旂殑绔彛鍙凤細
C:\> C:\mysql\bin\mysqladmin --port=3307 shutdown
C:\> C:\mysql\bin\mysqladmin --port=3308 shutdown
濡傚垰鎵嶆墍璁ㄨ鐨勶紝鏈嶅姟鍣ㄩ厤缃厑璁稿鎴风閫氳繃TCP/IP鏉ヨ繛鎺ャ傚鏋滀綘鐨Windows鐗堟湰鏀寔鍛藉悕绠¢亾骞朵笖浣犳兂鍏佽鍛藉悕绠¢亾杩炴帴锛屼娇鐢mysqld-nt鎴mysqld-max-nt鏈嶅姟鍣ㄥ苟鎸囧畾鍚敤鍛藉悕绠¢亾骞朵笖鎸囧畾绠¢亾鍚嶇殑閫夐」銆傛敮鎸佸懡鍚嶇閬撹繛鎺ョ殑姣忎釜鏈嶅姟鍣ㄥ繀椤讳娇鐢ㄤ竴涓敮涓鐨勭閬撳悕銆備緥濡傦紝C:\my-opts1.cnf鏂囦欢鍙兘璞¤繖鏍锋潵涔﹀啓锛
[mysqld]
datadir = C:/mydata1
port = 3307
enable-named-pipe
socket = mypipe1
鐒跺悗锛岃繖鏍峰惎鍔ㄦ湇鍔″櫒锛
C:\> C:\mysql\bin\mysqld-nt --defaults-file=C:\my-opts1.cnf
鍚屾牱淇敼绗2涓湇鍔″櫒浣跨敤鐨C:\my-opts2.cnf鏂囦欢銆
鍦ㄥ熀浜NT鐨勭郴缁熶腑锛MySQL鏈嶅姟鍣ㄥ彲浠ヤ互Windows鏈嶅姟鐨勬柟寮忔潵杩愯銆傚畨瑁呫佹帶鍒跺拰鍒犻櫎鍗曚釜MySQL鏈嶅姟鐨勮繃绋嬫弿杩拌2.3.12鑺傦紝鈥滀互Windows鏈嶅姟鏂瑰紡鍚姩MySQL鈥銆
浣犺繕鍙互浠ユ湇鍔$殑鏂瑰紡瀹夎澶氫釜MySQL鏈嶅姟鍣ㄣ傛鏃讹紝闄や簡鎵鏈夊弬鏁板姣忎釜鏈嶅姟鍣ㄥ繀椤绘槸鍞竴鐨勶紝浣犺繕蹇呴』纭繚姣忎釜鏈嶅姟鍣ㄤ娇鐢ㄤ笉鍚岀殑鏈嶅姟鍚嶃
鍦ㄤ笅闈㈢殑璇存槑涓紝鍋囪浣犳兂瑕佽繍琛mysqld-nt鏈嶅姟鍣ㄧ殑涓や釜涓嶅悓鐨勭増鏈紝瀹冧滑鍒嗗埆瀹夎鍦C:\mysql-4.1.8鍜C:\mysql-5.1.2-alpha鐩綍涓(鍙兘瀛樺湪杩欑鎯呭喌锛屽鏋滀綘姝e湪杩愯鐗堟湰4.1.8浣滀负浣犵殑浜у搧鏈嶅姟鍣紝杩樻兂浣跨敤5.1.2-alpha鐗堟湰鏉ヨ繘琛屾祴璇曪級銆
褰撶敤--install鎴--install-manual閫夐」瀹夎涓涓MySQL鏈嶅姟鏃讹紝搴旈伒浠庝互涓嬪師鍒欙細
路 濡傛灉浣犳病鏈夋寚瀹氭湇鍔″悕锛屾湇鍔″櫒浣跨敤榛樿鐨MySQL鏈嶅姟鍚嶏紝浠庢爣鍑嗛夐」鏂囦欢鐨[mysqld]缁勪腑璇诲彇閫夐」銆
路 濡傛灉浣犲湪--install閫夐」鍚庢寚瀹氫簡鏈嶅姟鍚嶏紝鏈嶅姟鍣ㄥ拷鐣[mysqld]閫夐」缁勶紝浠庡叿鏈夌浉鍚屽悕鐨勭粍涓鍙栭夐」浣滀负鏈嶅姟鍚嶃傛湇鍔″櫒浠庢爣鍑嗛夐」鏂囦欢涓鍙栭夐」銆
路 濡傛灉浣犲湪鏈嶅姟鍚嶅悗闈㈡寚瀹氫竴涓--defaults-file閫夐」锛屾湇鍔″櫒蹇界暐鏍囧噯閫夐」鏂囦欢锛屽彧浠庡懡鍚嶇殑鏂囦欢鐨[mysqld]缁勮鍙栭夐」銆
娉閲婏細MySQL 4.0.17涔嬪墠锛屽彧鏈変娇鐢ㄩ粯璁ゆ湇鍔″悕锛MySQL锛瀹夎鐨勪竴涓湇鍔″櫒鎴栦娇鐢ㄦ湇鍔″悕mysqld鏄惧紡瀹夎鐨勪竴涓湇鍔″櫒浠庢爣鍑嗛夐」鏂囦欢璇[mysqld]缁勩傚埌4.0.17鏃讹紝濡傛灉鏈嶅姟鍣ㄨ鏍囧噯閫夐」鏂囦欢锛屽垯瀹冧滑鍧囪[mysqld]缁勶紝鍗充娇瀹冧滑瀹夎鏃朵娇鐢ㄤ簡鍙︿竴涓湇鍔″悕銆傝繖鏍峰厑璁镐綘涓洪夐」浣跨敤[mysqld]缁勶紝鐢ㄤ簬鎵鏈MySQL鏈嶅姟鍣紝骞跺皢鏍规嵁姣忎釜鏈嶅姟鍣ㄥ懡鍚嶇殑閫夐」缁勭敤浜庤鏈嶅姟鍣锛屽嵆浣跨敤閭d釜鏈嶅姟鍚嶅畨瑁呯殑鏈嶅姟鍣ㄣ
鏍规嵁鍓嶉潰鍙欒堪锛屼綘鍙互閫氳繃鍑犱釜鏂规硶鏉ヨ缃涓湇鍔″櫒銆備笅闈㈢殑璇存槑鎻忚堪浜嗕竴浜涚ず渚嬨傚湪灏濊瘯涔嬪墠锛屽簲纭繚浣犻鍏堝叧闂苟涓斿嵏杞戒簡鎵鏈夊凡鏈夌殑MySQL鏈嶅姟鍣ㄣ
路 鏂规硶1锛鍦ㄤ竴涓爣鍑嗛夐」鏂囦欢涓寚瀹氭墍鏈夋湇鍔″櫒閫夐」銆傝鎯宠繖鏍峰仛锛屼负姣忎釜鏈嶅姟鍣ㄤ娇鐢ㄤ笉鍚岀殑鏈嶅姟鍚嶃傚亣璁句綘鎯充娇鐢ㄦ湇鍔″悕mysqld1杩愯4.1.8鐗堢殑mysqld-nt骞浣跨敤鏈嶅姟鍚mysqld2杩愯5.1.2-alpha鐗堢殑mysqld-nt銆傚湪杩欑鎯呭喌涓嬶紝浣犲彲浠ヤ负4.1.8浣跨敤[mysqld1]缁勶紝涓5.1.2-alpha浣跨敤[mysqld2]缁勩備緥濡傦紝浣犲彲浠ヨ薄杩欐牱寤虹珛 C:\my.cnf鏂囦欢锛
路 # options for mysqld1 service
路 [mysqld1]
路 basedir = C:/mysql-4.1.8
路 port = 3307
路 enable-named-pipe
路 socket = mypipe1
路
路 # options for mysqld2 service
路 [mysqld2]
路 basedir = C:/mysql-5.1.2-alpha
路 port = 3308
路 enable-named-pipe
路 socket = mypipe2
濡備笅闈㈡墍绀哄畨瑁呮湇鍔″櫒锛屼娇鐢ㄦ湇鍔″櫒鐨勫叏璺緞鍚嶆潵纭繚Windows涓烘瘡涓湇鍔℃敞鍐屾纭殑鍙墽琛岀▼搴忥細
C:\> C:\mysql-4.1.8\bin\mysqld-nt --install mysqld1
C:\> C:\mysql-5.1.2-alpha\bin\mysqld-nt --install mysqld2
涓轰簡鍚姩鏈嶅姟鍣紝浣跨敤鏈嶅姟绠$悊鍣紝鎴栫敤甯︽湁閫傚綋鐨勬湇鍔″悕鐨NET START锛
C:\> NET START mysqld1
C:\> NET START mysqld2
瑕佹兂鍋滄鏈嶅姟锛屼娇鐢ㄦ湇鍔$鐞嗗櫒锛屾垨鐢ㄥ甫鏈夐傚綋鐨勬湇鍔″悕鐨NET STOP锛
C:\> NET STOP mysqld1
C:\> NET STOP mysqld2
路 鏂规硶2锛涓烘瘡涓湇鍔″櫒鐢ㄤ笉鍚岀殑鏂囦欢鎸囧畾閫夐」锛屽綋浣犲畨瑁呮湇鍔℃椂浣跨敤--defaults-file鍛婅瘔姣忎釜鏈嶅姟鍣ㄤ娇鐢ㄤ粈涔堟枃浠躲傛鏃讹紝姣忎釜鏂囦欢搴旂敤涓涓[mysqld]缁勫垪鍑洪夐」銆
浣跨敤杩欑鏂规硶涓4.1.8鐗堟湰鐨mysqld-nt鎸囧畾閫夐」锛屽簲璞¤繖鏍峰垱寤轰竴涓C:\my-opts1.cnf鏂囦欢锛
[mysqld]
basedir = C:/mysql-4.1.8
port = 3307
enable-named-pipe
socket = mypipe1
瀵逛簬5.1.2-alpha鐗堢殑mysqld-nt锛岃薄杩欐牱鍒涘缓涓涓C:\my-opts2.cnf鏂囦欢锛
[mysqld]
basedir = C:/mysql-5.1.2-alpha port = 3308
enable-named-pipe
socket = mypipe2
瀹夎鏈嶅姟濡備笅锛堝湪涓涓崟涓琛屼腑杈撳叆姣忎釜鍛戒护锛夛細
C:\> C:\mysql-4.1.8\bin\mysqld-nt -- installmysqld1
--defaults-file=C:\my-opts1.cnf
C:\> C:\mysql-5.1.2-alpha\bin\mysqld-nt -- installmysqld2
--defaults-file=C:\my-opts2.cnf
褰撲綘浣滀负鏈嶅姟瀹夎涓涓MySQL鏈嶅姟鍣ㄦ椂锛岃鎯充娇鐢--defaults-file閫夐」锛屼綘蹇呴』鍦ㄦ閫夐」涔嬪墠鍔犳湇鍔″悕銆
瀹夎鏈嶅姟鍚庯紝鎸夌収涓庡墠闈㈢殑绀轰緥鐩稿悓鐨勬柟娉曞惎鍔ㄥ拰鍋滄銆
瑕佹兂鍗歌浇澶氫釜鏈嶅姟锛屽姣忎釜鏈嶅姟浣跨敤mysqld --remove锛屽湪--remove閫夐」鍚庢寚瀹氭湇鍔″悕銆傚鏋滄湇鍔″悕鏄 榛樿鐨(MySQL)锛屼綘鍙互涓嶆寚瀹氥
鍦Unix涓繍琛屽涓湇鍔″櫒鏈瀹规槗鐨勬柟娉曟槸浣跨敤涓嶅悓鐨TCP/IP绔彛s鍜Unix濂楁帴瀛楁枃浠剁紪璇戯紝鍥犳姣忎釜瀹炰緥鍦ㄤ笉鍚岀殑缃戠粶鎺ュ彛渚﹀惉銆傚彟澶栵紝姣忎釜瀹夎搴斿湪涓嶅悓鐨勫熀纭鐩綍涓紪璇戯紝閭e皢鑷姩涓轰綘鐨勬瘡涓湇鍔″櫒浜х敓浣跨敤涓嶅悓鐨勭紪璇戣繘鏉ョ殑鏁版嵁鐩綍銆佹棩蹇楁枃浠跺拰PID鏂囦欢浣嶇疆銆
鍋囪涓涓幇鏈夌殑4.1.8鐗堟湰鏈嶅姟鍣ㄩ厤缃负榛樿TCP/IP绔彛鍙(3306)鍜Unix濂楁帴瀛楁枃浠(/tmp/mysql.sock)銆傝鎯抽厤缃竴涓柊鐨5.1.2-alpha鐗堢殑鏈嶅姟鍣ㄦ潵浣跨敤涓嶅悓鐨勬搷浣滃弬鏁帮紝浣跨敤涓涓configure鍛戒护锛屽ぇ姒傝薄杩欐牱浣跨敤锛
shell> ./configure --with-tcp-port=port_number \
--with-unix-socket-path=file_name \
--prefix=/usr/local/mysql-5.1.2-alpha
杩欓噷锛port_number鍜file_name蹇呴』涓嶅悓浜庨粯璁TCP/IP绔彛鍙峰拰Unix濂楁帴瀛楁枃浠惰矾寰勫悕锛屽苟涓--prefix鍊煎簲鎸囧畾涓涓笉鍚屼簬鐜版湁MySQL瀹夎鐩綍鐨勫畨瑁呯洰褰曘
濡傛灉浣犳湁涓涓MySQL鏈嶅姟鍣ㄦ渚﹀惉涓涓粰瀹氱殑绔彛鍙凤紝浣犲彲浠ヤ娇鐢ㄤ笅闈㈢殑鍛戒护鏉ユ壘鍑洪拡瀵逛竴浜涢噸瑕侀厤缃彉閲忓畠浣跨敤浜嗛偅浜涙搷浣滃弬鏁帮紝鍖呮嫭鍩虹鐩綍鍜Unix濂楁帴瀛楁枃浠跺悕锛
shell> mysqladmin --host=host_name --port=port_number variables
閫氳繃璇ュ懡浠ゆ樉绀虹殑淇℃伅锛屽綋閰嶇疆鍏跺畠鏈嶅姟鍣ㄦ椂锛屼綘鍙互鍛婅瘔鏈嶅姟鍣ㄨ閫夐」娌℃湁浣跨敤鐨勫笺
璇锋敞鎰忥紝濡傛灉浣犳寚瀹localhost浣滀负涓涓富鏈哄悕锛mysqladmin榛樿浣跨敤Unix濂楁帴瀛楁枃浠惰繛鎺ワ紝鑰屼笉鏄TCP/IP銆備粠 MySQL 4.1寮濮嬶紝閫氳繃--protocol= TCP | SOCKET | PIPE | MEMORY}閫夐」锛屼綘鍙互鏄剧ず鍦版寚瀹氳繛鎺ュ崗璁
濡傛灉鍙槸鐢ㄤ竴涓笉鍚岀殑Unix濂楁帴瀛楁枃浠跺拰TCP/IP绔彛鍙峰惎鍔紝涓嶅繀缂栬瘧鏂扮殑MySQL鏈嶅姟鍣ㄣ傝繕鍙互鍦ㄨ繍琛屾椂鎸囧畾杩欎簺鍊笺傝繖鏍峰仛鐨勪竴涓柟娉曟槸浣跨敤鍛戒护琛岄夐」锛
shell> mysqld_safe --socket=file_name --port=port_number
瑕佸惎鍔ㄧ浜屼釜鏈嶅姟鍣紝鎻愪緵涓嶅悓鐨--socket鍜--port閫夐」鍊硷紝骞朵笖浼犻掍竴涓--datadir=path閫夐」缁mysqld_safe锛屼互渚挎湇鍔″櫒浣跨敤涓涓笉鍚岀殑鏁版嵁鐩綍銆
杈惧埌鐩镐技鏁堟灉鐨勫彟涓涓柟娉曟槸浣跨敤鐜鍙橀噺鏉ヨ缃 Unix濂楁帴瀛楁枃浠跺悕鍜TCP/IP绔彛鍙凤細
shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
shell> MYSQL_TCP_PORT=3307
shell> export MYSQL_UNIX_PORT MYSQL_TCP_PORT
shell> mysql_install_db --user=mysql
shell> mysqld_safe --datadir=/path/to/datadir &
杩欐槸涓涓揩閫熷惎鍔ㄧ浜屼釜鏈嶅姟鍣ㄤ互鐢ㄤ簬娴嬭瘯鐨勬柟娉曘傝鏂规硶鐨勬渶澶уソ澶勬槸鐜鍙橀噺璁惧畾鍊奸傜敤浜庝綘浠庣浉鍚岀殑shell璋冪敤鐨勪换浣曞鎴风绋嬪簭銆傚洜鑰岋紝閭d簺瀹㈡埛绔繛鎺ヨ嚜鍔ㄦ寚鍚戠浜屼釜鏈嶅姟鍣紒
闄勫綍F锛鐜鍙橀噺鍖呮嫭浣犲彲浠ヤ娇鐢ㄧ殑褰卞搷mysqld鐨勫叾瀹冪幆澧冨彉閲忓垪琛銆
瀵逛簬鑷姩鏈嶅姟鍣ㄥ惎鍔紝瀵逛簬姣忎釜鏈嶅姟鍣紝鏈哄櫒寮曞鏃舵墽琛岀殑鍚姩鑴氭湰搴旀墽琛屼笅闈㈢殑鍛戒护锛屾瘡涓懡浠ょ敤涓涓浉搴旂殑閫夐」鏂囦欢璺緞锛
mysqld_safe --defaults-file=path
姣忎釜閫夐」鏂囦欢搴斿寘鍚竴涓粰瀹氭湇鍔″櫒鐗瑰畾鐨勯夐」鍊笺
鍦Unix涓紝mysqld_multi鑴氭湰鏄惎鍔ㄥ涓湇鍔″櫒鐨勫彟涓涓柟娉曘傚弬瑙5.1.5鑺傦紝鈥渕ysqld_multi锛氱鐞嗗涓狹ySQL鏈嶅姟鍣ㄧ殑绋嬪簭鈥銆
褰撲綘鎯宠鐢ㄤ竴涓鎴风绋嬪簭杩炴帴涓涓MySQL鏈嶅姟鍣ㄦ椂锛岃鏈嶅姟鍣ㄤ睛鍚笉鍚岀殑缃戠粶鎺ュ彛锛岃屼笉鏄紪璇戝埌浣犵殑瀹㈡埛绔殑缃戠粶鎺ュ彛锛屼綘鍙互浣跨敤涓嬮潰鐨勬柟娉曪細
路 鍚姩瀹㈡埛绔紝鐢--host=host_name --port=port_number閫氳繃TCP/IP鏉ヨ繛鎺ヤ竴涓繙绋嬫湇鍔″櫒锛岀敤--host=127.0.0.1 --port=port_number閫氳繃TCP/IP鏉ヨ繛鎺ヤ竴涓湰鍦版湇鍔″櫒锛屾垨鑰呯敤--host=localhost --socket=file_name閫氳繃涓涓Unix濂楁帴瀛楁枃浠舵垨涓涓Windows鍛藉悕绠¢亾鏉ヨ繛鎺ヤ竴涓湰鍦版湇鍔″櫒銆
路 浠MySQL 4.1璧凤紝鍚姩瀹㈡埛绔椂鐢--protocol=tcp閫氳繃TCP/IP鏉ヨ繛鎺ワ紝鐢--protocol=socket閫氳繃涓涓Unix濂楁帴瀛楁枃浠舵潵杩炴帴锛岀敤--protocol=pipe閫氳繃涓涓懡鍚嶇閬撴潵杩炴帴锛屾垨鐢--protocol=memory閫氳繃鍏变韩鍐呭瓨鏉ヨ繛鎺ャ傚浜TCP/IP杩炴帴锛屼綘鍙兘杩橀渶瑕佹寚瀹--host鍜--port閫夐」銆傚浜庡叾瀹冪被鍨嬬殑杩炴帴锛屼綘鍙兘闇瑕佹寚瀹氫竴涓--socket閫夐」鏉ユ寚瀹氫竴涓Unix濂楁帴瀛楁枃浠舵垨鍛藉悕绠¢亾鍚嶏紝鎴栬呬竴涓--shared-memory-base-name閫夐」鏉ユ寚瀹氬叡浜唴瀛樺悕銆傚叡浜唴瀛樿繛鎺ヤ粎鍦Windows涓敮鎸併
路 鍦Unix涓紝鍦ㄤ綘鍚姩瀹㈡埛绔箣鍓嶏紝璁剧疆MYSQL_UNIX_PORT鍜MYSQL_TCP_PORT鐜鍙橀噺鏉ユ寚瀹Unix濂楁帴瀛楁枃浠跺拰TCP/IP绔彛鍙枫傚鏋滀綘缁忓父浣跨敤鍏蜂綋鐨勫鎺ュ瓧鏂囦欢鎴栫鍙e彿锛屼綘鍙互鍦.login鏂囦欢涓斁缃懡浠ゆ潵璁剧疆鐜鍙橀噺浠ヤ究浣犳瘡娆$櫥褰曟椂璇ュ懡浠よ捣浣滅敤銆傚弬瑙闄勫綍F锛鐜鍙橀噺銆
路 鍦ㄤ竴涓夐」鏂囦欢鐨[client]缁勪腑鎸囧畾榛樿Unix濂楁帴瀛楁枃浠跺拰TCP/IP绔彛鍙枫備緥濡傦紝浣犲彲浠ュ湪Windows涓娇鐢C:\my.cnf鏂囦欢锛屾垨鍦Unix涓富鐩綍鍐呬娇鐢.my.cnf鏂囦欢銆傚弬瑙4.3.2鑺傦紝鈥滀娇鐢ㄩ夐」鏂囦欢鈥銆
路 鍦C绋嬪簭涓紝鍦mysql_real_connect()璋冪敤鏃讹紝浣犲彲浠ユ寚瀹氬鎺ュ瓧鏂囦欢鎴栫鍙e彿鍙傛暟銆傞氳繃璋冪敤mysql_options()锛浣犺繕鍙互鏈夌▼搴忚閫夐」鏂囦欢銆傚弬瑙25.2.3鑺傦紝鈥淐 API鍑芥暟鎻忚堪鈥銆
路 濡傛灉浣犳鍦ㄤ娇鐢Perl DBD::mysql妯″潡锛屼綘鍙互浠MySQL閫夐」鏂囦欢涓鍙栭夐」銆備緥濡傦細
路 $dsn = "DBI:mysql:test;mysql_read_default_group=client;"
路 . "mysql_read_default_file=/usr/local/mysql/data/my.cnf";
路 $dbh = DBI->connect($dsn, $user, $password);
鍏跺畠绋嬪簭鎺ュ彛鍙互涓鸿閫夐」鏂囦欢鎻愪緵鐩镐技鐨勫姛鑳姐
鏌ヨ缂撳瓨瀛樺偍SELECT鏌ヨ鐨勬枃鏈互鍙婂彂閫佺粰瀹㈡埛绔殑鐩稿簲缁撴灉銆傚鏋滈殢鍚庢敹鍒颁竴涓浉鍚岀殑鏌ヨ锛屾湇鍔″櫒浠庢煡璇㈢紦瀛樹腑閲嶆柊寰楀埌鏌ヨ缁撴灉锛岃屼笉鍐嶉渶瑕佽В鏋愬拰鎵ц鏌ヨ銆
濡傛灉浣犳湁涓涓笉缁忓父鏀瑰彉鐨勮〃骞朵笖鏈嶅姟鍣ㄦ敹鍒拌琛ㄧ殑澶ч噺鐩稿悓鏌ヨ锛屾煡璇㈢紦瀛樺湪杩欐牱鐨勫簲鐢ㄧ幆澧冧腑鍗佸垎鏈夌敤銆傚浜庤澶Web鏈嶅姟鍣ㄦ潵璇村瓨鍦ㄨ繖绉嶅吀鍨嬫儏鍐碉紝瀹冩牴鎹暟鎹簱鍐呭鐢熸垚澶ч噺鐨勫姩鎬侀〉闈€
娉閲婏細鏌ヨ缂撳瓨涓嶈繑鍥炴棫鐨勬暟鎹傚綋琛ㄦ洿鏀瑰悗锛屾煡璇㈢紦瀛樺肩殑鐩稿叧鏉$洰琚竻绌恒
娉閲婏細濡傛灉浣犳湁璁稿mysqld鏈嶅姟鍣ㄦ洿鏂扮浉鍚岀殑MyISAM琛紝鍦ㄨ繖绉嶆儏鍐典笅鏌ヨ缂撳瓨涓嶈捣浣滅敤銆
娉閲婏細鏌ヨ缂撳瓨涓嶉傜敤浜庢湇鍔″櫒鏂圭紪鍐欑殑璇彞銆傚鏋滄鍦ㄤ娇鐢ㄦ湇鍔″櫒鏂圭紪鍐欑殑璇彞锛岃鑰冭檻鍒拌繖浜涜鍙ュ皢涓嶄細搴旂敤鏌ヨ缂撳瓨銆傚弬瑙 25.2.4鑺傦紝鈥淐 API棰勫鐞嗚鍙モ銆
涓嬮潰鏄煡璇㈢紦瀛樼殑涓浜涙ц兘鏁版嵁銆傝繖浜涚粨鏋滄槸鍦Linux Alpha 2 x 500MHz绯荤粺锛2GB RAM锛64MB鏌ヨ缂撳瓨锛変笂杩愯MySQL鍩哄噯缁勪欢浜х敓鐨勩
路 濡傛灉鎵ц鐨勬墍鏈夋煡璇㈡槸绠鍗曠殑(濡備粠鍙湁涓琛屾暟鎹殑琛ㄤ腑閫夊彇涓琛)锛屼絾鏌ヨ鏄笉鍚岀殑锛屾煡璇笉鑳借缂撳瓨锛屾煡璇㈢紦瀛樻縺娲荤巼鏄13%銆傝繖鍙互鐪嬩綔鏄渶鍧忕殑鎯呭舰銆傚湪瀹為檯搴旂敤涓紝鏌ヨ瑕佸鏉傚緱澶氾紝鍥犳锛屾煡璇㈢紦瀛樹娇鐢ㄧ巼涓鑸細寰堜綆銆
路 浠庡彧鏈変竴琛岀殑琛ㄤ腑鏌ユ壘涓琛屾暟鎹椂锛屼娇鐢ㄦ煡璇㈢紦瀛樻瘮涓嶄娇鐢ㄩ熷害蹇238%銆傝繖鍙互鐪嬩綔鏌ヨ浣跨敤缂撳瓨鏃堕熷害鎻愰珮鏈灏忕殑鎯呭喌銆
鏈嶅姟鍣ㄥ惎鍔ㄦ椂瑕佺鐢ㄦ煡璇㈢紦瀛橈紝璁剧疆query_cache_size绯荤粺鍙橀噺涓0銆傜鐢ㄦ煡璇㈢紦瀛樹唬鐮佸悗锛娌℃湁鏄庢樉鐨勯熷害鎻愰珮銆缂栬瘧MySQL鏃讹紝閫氳繃鍦configure涓浣跨敤--without-query-cache閫夐」锛屽彲浠ヤ粠鏈嶅姟鍣ㄤ腑褰诲簳鍘婚櫎鏌ヨ缂撳瓨鑳藉姏銆
鏈妭鎻忚堪鏌ヨ缂撳瓨鐨勫伐浣滃師鐞嗐5.13.3鑺傦紝鈥滄煡璇㈤珮閫熺紦鍐查厤缃鎻忚堪浜嗘庢牱鎺у埗鏄惁浣跨敤鏌ヨ缂撳瓨銆
鏌ヨ瑙f瀽涔嬪墠杩涜姣旇緝锛屽洜姝や笅闈㈢殑涓や釜鏌ヨ琚煡璇㈢紦瀛樿涓烘槸涓嶇浉鍚岀殑锛
SELECT * FROM tbl_name
Select * from tbl_name
鏌ヨ蹇呴』鏄畬鍏ㄧ浉鍚岀殑(閫愬瓧鑺傜浉鍚)鎵嶈兘澶熻璁や负鏄浉鍚岀殑銆傚彟澶栵紝鍚屾牱鐨勬煡璇㈠瓧绗︿覆鐢变簬鍏跺畠鍘熷洜鍙兘璁や负鏄笉鍚岀殑銆備娇鐢ㄤ笉鍚岀殑鏁版嵁搴撱佷笉鍚岀殑鍗忚鐗堟湰鎴栬呬笉鍚 榛樿瀛楃闆嗙殑鏌ヨ琚涓烘槸涓嶅悓鐨勬煡璇㈠苟涓斿垎鍒繘琛岀紦瀛樸
浠庢煡璇㈢紦瀛樹腑鎻愬彇涓涓煡璇箣鍓嶏紝MySQL妫鏌ョ敤鎴峰鎵鏈夌浉鍏虫暟鎹簱鍜岃〃鐨SELECT鏉冮檺銆濡傛灉娌℃湁鏉冮檺锛涓嶄娇鐢ㄧ紦瀛樼粨鏋溿
濡傛灉浠庢煡璇㈢紦瀛樹腑杩斿洖涓涓煡璇㈢粨鏋滐紝鏈嶅姟鍣ㄦ妸Qcache_hits鐘舵佸彉閲忕殑鍊煎姞涓锛岃屼笉鏄Com_select鍙橀噺銆傚弬瑙5.13.4鑺傦紝鈥滄煡璇㈤珮閫熺紦鍐茬姸鎬佸拰缁存姢鈥銆
濡傛灉涓涓〃琚洿鏀逛簡锛岄偅涔堜娇鐢ㄩ偅涓〃鐨勬墍鏈夌紦鍐叉煡璇㈠皢涓嶅啀鏈夋晥锛屽苟涓斾粠缂撳啿鍖轰腑绉诲嚭銆傝繖鍖呮嫭閭d簺鏄犲皠鍒版敼鍙樹簡鐨勮〃鐨勪娇鐢MERGE琛ㄧ殑鏌ヨ銆備竴涓〃鍙互琚澶氱被鍨嬬殑璇彞鏇存敼锛屼緥濡INSERT銆UPDATE銆DELETE銆TRUNCATE銆ALTER TABLE銆DROP TABLE鎴DROP DATABASE銆
COMMIT鎵ц瀹屽悗锛岃鏇存敼鐨勪簨鍔InnoDB琛ㄤ笉鍐嶆湁鏁堛
浣跨敤InnoDB琛ㄦ椂锛屾煡璇㈢紦瀛樹篃鍦ㄤ簨鍔′腑宸ヤ綔锛屼娇鐢ㄨ琛ㄧ殑鐗堟湰鍙锋潵妫娴嬪叾鍐呭鏄惁浠嶆棫鏄綋鍓嶇殑銆
鍦MySQL 5.1涓紝瑙嗗浘浜х敓鐨勬煡璇㈣缂撳瓨銆
SELECT SQL_CALC_FOUND_ROWS ...鍜SELECT FOUND_ROWS() type绫诲瀷鐨勬煡璇娇鐢ㄦ煡璇㈢紦瀛樸傚嵆浣垮洜鍒涘缓鐨勮鏁颁篃琚繚瀛樺湪缂撳啿鍖哄唴锛屽墠闈㈢殑鏌ヨ浠庣紦瀛樹腑鎻愬彇锛FOUND_ROWS()涔熻繑鍥炴纭殑鍊笺
濡傛灉涓涓煡璇㈠寘鍚笅闈㈠嚱鏁颁腑鐨勪换浣曚竴涓紝瀹冧笉浼氳缂撳瓨锛
BENCHMARK() |
CONNECTION_ID() |
CURDATE() |
CURRENT_DATE() |
CURRENT_TIME() |
CURRENT_TIMESTAMP() |
CURTIME() |
DATABASE() |
甯︿竴涓弬鏁扮殑ENCRYPT() |
FOUND_ROWS() |
GET_LOCK() |
LAST_INSERT_ID() |
LOAD_FILE() |
MASTER_POS_WAIT() |
NOW() |
RAND() |
RELEASE_LOCK() |
SYSDATE() |
涓嶅甫鍙傛暟鐨UNIX_TIMESTAMP() |
USER() |
|
鍦ㄤ笅闈㈢殑杩欎簺鏉′欢涓嬶紝鏌ヨ涔熶笉浼氳缂撳瓨锛
路 寮曠敤鑷畾涔夊嚱鏁(UDFs)銆
路 寮曠敤鑷畾涔夊彉閲忋
路 寮曠敤mysql绯荤粺鏁版嵁搴撲腑鐨勮〃銆
路 涓嬮潰鏂瑰紡涓殑浠讳綍涓绉嶏細
SELECT ...IN SHARE MODE
SELECT ...FOR UPDATE
SELECT ...INTO OUTFILE ...
SELECT ...INTO DUMPFILE ...
SELECT * FROM ...WHERE autoincrement_col IS NULL
鏈鍚庝竴绉嶆柟寮忎笉鑳借缂撳瓨鏄洜涓哄畠琚敤浣滀负ODBC宸ヤ綔鍖烘潵鑾峰彇鏈杩戞彃鍏ョ殑ID鍊笺傚弬瑙26.1.14.1鑺傦紝鈥滃浣曞湪ODBC涓幏鍙朅UTO_INCREMENT鍒楃殑鍊鈥銆
路 琚綔涓虹紪鍐欏ソ鐨勮鍙ワ紝鍗充娇娌℃湁浣跨敤鍗犱綅绗︺備緥濡傦紝涓嬮潰浣跨敤鐨勬煡璇細
char *my_sql_stmt = "SELECT a锛b FROM table_c";
/* ...*/
mysql_stmt_prepare(stmt锛my_sql_stmt锛strlen(my_sql_stmt));
涓嶈缂撳瓨銆傚弬瑙25.2.4鑺傦紝鈥淐 API棰勫鐞嗚鍙モ銆
路 浣跨敤TEMPORARY琛ㄣ
路 涓嶄娇鐢ㄤ换浣曡〃銆
路 鐢ㄦ埛鏈夋煇涓〃鐨勫垪绾ф潈闄愩
閫氳繃have_query_cache鏈嶅姟鍣ㄧ郴缁熷彉閲忔寚绀烘煡璇㈢紦瀛樻槸鍚﹀彲鐢細
mysql> SHOW VARIABLES LIKE 'have_query_cache';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| have_query_cache | YES |
+------------------+-------+
鍗充娇绂佺敤鏌ヨ缂撳瓨锛屽綋浣跨敤鏍囧噯 MySQL浜岃繘鍒舵椂锛岃繖涓兼绘槸YES銆
鍏跺畠鍑犱釜绯荤粺鍙橀噺鎺у埗鏌ヨ缂撳瓨鎿嶄綔銆傚綋鍚姩mysqld鏃讹紝杩欎簺鍙橀噺鍙互鍦ㄩ夐」鏂囦欢鎴栬呭懡浠よ涓缃傛墍鏈夋煡璇㈢紦瀛樼郴缁熷彉閲忓悕浠query_cache_ 寮澶淬傚畠浠殑璇︾粏鎻忚堪瑙5.3.3鑺傦紝鈥滄湇鍔″櫒绯荤粺鍙橀噺鈥锛岃繕缁欏嚭浜嗛澶栫殑閰嶇疆淇℃伅銆
涓轰簡璁剧疆鏌ヨ缂撳瓨澶у皬锛岃缃query_cache_size绯荤粺鍙橀噺銆傝缃负0琛ㄧず绂佺敤鏌ヨ缂撳瓨銆 榛樿缂撳瓨澶у皬璁剧疆涓0锛涗篃灏辨槸绂佺敤鏌ヨ缂撳瓨銆
褰撹缃query_cache_size鍙橀噺涓洪潪闆跺兼椂锛屽簲璁颁綇鏌ヨ缂撳瓨鑷冲皯澶х害闇瑕40KB鏉ュ垎閰嶅叾鏁版嵁缁撴瀯銆(鍏蜂綋澶у皬鍙栧喅浜庣郴缁熺粨鏋勶級銆濡傛灉浣犳妸璇ュ艰缃殑澶皬锛屽皢浼氬緱鍒颁竴涓鍛婏紝濡傛湰渚嬫墍绀猴細
mysql> SET GLOBAL query_cache_size = 40000;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SHOW WARNINGS\G
*************************** 1. row ***************************
Level: Warning
Code: 1282
Message: Query cache failed to set size 39936; new query cache size is 0
mysql> SET GLOBAL query_cache_size = 41984;
Query OK, 0 rows affected (0.00 sec)
mysql> SHOW VARIABLES LIKE 'query_cache_size';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| query_cache_size | 41984 |
+------------------+-------+
濡傛灉鏌ヨ缂撳瓨澶у皬璁剧疆涓哄ぇ浜0锛query_cache_type鍙橀噺褰卞搷鍏跺伐浣滄柟寮忋傝繖涓彉閲忓彲浠ヨ缃负涓嬮潰鐨勫硷細
路 0鎴OFF灏嗛樆姝㈢紦瀛樻垨鏌ヨ缂撳瓨缁撴灉銆
路 1鎴ON灏嗗厑璁哥紦瀛橈紝浠SELECT SQL_NO_CACHE寮濮嬬殑鏌ヨ璇彞闄ゅ銆
路 2鎴DEMAND锛屼粎瀵逛互SELECT SQL_CACHE寮濮嬬殑閭d簺鏌ヨ璇彞鍚敤缂撳瓨銆
璁剧疆query_cache_type鍙橀噺鐨GLOBAL鍊煎皢鍐冲畾鏇存敼鍚庢墍鏈夎繛鎺ュ鎴风鐨勭紦瀛樿涓恒傚叿浣撳鎴风鍙互閫氳繃璁剧疆query_cache_type鍙橀噺鐨勪細璇濆兼帶鍒跺畠浠湰韬繛鎺ョ殑缂撳瓨琛屼负銆備緥濡傦紝涓涓鎴峰彲浠ョ鐢ㄨ嚜宸辩殑鏌ヨ缂撳瓨锛屾柟娉曞涓嬶細
mysql> SET SESSION query_cache_type = OFF;
瑕佹帶鍒跺彲浠ヨ缂撳瓨鐨勫叿浣撴煡璇㈢粨鏋滅殑鏈澶у硷紝搴旇缃query_cache_limit鍙橀噺銆 榛樿鍊兼槸1MB銆
褰撲竴涓煡璇㈢粨鏋滐紙杩斿洖缁欏鎴风鐨勬暟鎹級浠庢煡璇㈢紦鍐蹭腑鎻愬彇鏈熼棿锛屽畠鍦ㄦ煡璇㈢紦瀛樹腑鎺掑簭銆傚洜姝わ紝鏁版嵁閫氬父涓嶅湪澶х殑鏁版嵁鍧椾腑澶勭悊銆傛煡璇㈢紦瀛樻牴鎹暟鎹帓搴忚姹傚垎閰嶆暟鎹潡锛屽洜姝わ紝褰撲竴涓暟鎹潡鐢ㄥ畬鍚庡垎閰嶄竴涓柊鐨勬暟鎹潡銆傚洜涓哄唴瀛樺垎閰嶆搷浣滄槸鏄傝吹鐨(璐规椂鐨)锛屾墍浠ラ氳繃query_cache_min_res_unit绯荤粺鍙橀噺缁欐煡璇㈢紦瀛樺垎閰嶆渶灏忓笺傚綋鏌ヨ鎵ц鏃讹紝鏈鏂扮殑缁撴灉鏁版嵁鍧楁牴鎹疄闄呮暟鎹ぇ灏忔潵纭畾锛屽洜姝ゅ彲浠ラ噴鏀句笉浣跨敤鐨勫唴瀛樸傛牴鎹綘鐨勬湇鍔″櫒鎵ц鏌ヨ鐨勭被鍨嬶紝浣犱細鍙戠幇璋冩暣query_cache_min_res_unit鍙橀噺鐨勫兼槸鏈夌敤鐨勶細
路 query_cache_min_res_unit榛樿鍊兼槸4KB銆傝繖搴旇閫傚悎澶ч儴鍒嗘儏鍐点
路 濡傛灉浣犳湁澶ч噺杩斿洖灏忕粨鏋滄暟鎹殑鏌ヨ锛岄粯璁ゆ暟鎹潡澶у皬鍙兘浼氬鑷村唴瀛樼鐗囷紝鏄剧ず涓哄ぇ閲忕┖闂插唴瀛樺潡銆傜敱浜庣己灏戝唴瀛橈紝鍐呭瓨纰庣墖浼氬己鍒舵煡璇㈢紦瀛樹粠缂撳瓨鍐呭瓨涓慨鏁达紙鍒犻櫎锛夋煡璇€傝繖鏃讹紝浣犲簲璇ュ噺灏query_cache_min_res_unit鍙橀噺鐨勫笺傜┖闂插潡鍜岀敱浜庝慨鏁磋岀Щ鍑虹殑鏌ヨ鐨勬暟閲忛氳繃Qcache_free_blocks鍜Qcache_lowmem_prunes鍙橀噺鐨勫肩粰鍑恒
路 濡傛灉澶ч噺鏌ヨ杩斿洖澶х粨鏋滐紙妫鏌 Qcache_total_blocks鍜Qcache_queries_in_cache鐘舵佸彉閲忥級锛屼綘鍙互閫氳繃澧炲姞query_cache_min_res_unit鍙橀噺鐨勫兼潵鎻愰珮鎬ц兘銆備絾鏄紝娉ㄦ剰涓嶈浣垮畠鍙樺緱澶ぇ锛堝弬瑙佸墠闈㈢殑鏉$洰锛夈
鍙互浣跨敤涓嬮潰鐨勮鍙ユ鏌MySQL鏈嶅姟鍣ㄦ槸鍚︽彁渚涙煡璇㈢紦瀛樺姛鑳斤細
mysql> SHOW VARIABLES LIKE 'have_query_cache';
+------------------+-------+
| Variable_name | Value |
+------------------+-------+
| have_query_cache | YES |
+------------------+-------+
鍙互浣跨敤FLUSH QUERY CACHE璇彞鏉ユ竻鐞嗘煡璇㈢紦瀛樼鐗囦互鎻愰珮鍐呭瓨浣跨敤鎬ц兘銆傝璇彞涓嶄粠缂撳瓨涓Щ鍑轰换浣曟煡璇€
RESET QUERY CACHE璇彞浠庢煡璇㈢紦瀛樹腑绉诲嚭鎵鏈夋煡璇€FLUSH TABLES璇彞涔熸墽琛屽悓鏍风殑宸ヤ綔銆
涓轰簡鐩戣鏌ヨ缂撳瓨鎬ц兘锛屼娇鐢SHOW STATUS鏌ョ湅缂撳瓨鐘舵佸彉閲忥細
mysql> SHOW STATUS LIKE 'Qcache%';
+-------------------------+--------+
|鍙橀噺鍚 |鍊 |
+-------------------------+--------+
| Qcache_free_blocks | 36 |
| Qcache_free_memory | 138488 |
| Qcache_hits | 79570 |
| Qcache_inserts | 27087 |
| Qcache_lowmem_prunes | 3114 |
| Qcache_not_cached | 22989 |
| Qcache_queries_in_cache | 415 |
| Qcache_total_blocks | 912 |
+-------------------------+--------+
杩欎簺鍙橀噺鐨勬弿杩拌5.3.4鑺傦紝鈥滄湇鍔″櫒鐘舵佸彉閲忊銆傝繖閲屾弿杩板畠浠殑涓浜涘簲鐢ㄣ
SELECT鏌ヨ鐨勬绘暟閲忕瓑浠蜂簬锛
Com_select
+ Qcache_hits
+ queries with errors found by parser
Com_select鐨勫肩瓑浠蜂簬锛
Qcache_inserts
+ Qcache_not_cached
+ queries with errors found during columns/rights check
鏌ヨ缂撳瓨浣跨敤闀垮害鍙彉鍧楋紝鍥犳Qcache_total_blocks鍜Qcache_free_blocks鍙互鏄剧ず鏌ヨ缂撳瓨鍐呭瓨纰庣墖銆傛墽琛FLUSH QUERY CACHE鍚庯紝鍙繚鐣欎竴涓┖闂插潡銆
姣忎釜缂撳瓨鏌ヨ鑷冲皯闇瑕佷袱涓潡锛堜竴涓潡鐢ㄤ簬鏌ヨ鏂囨湰锛屼竴涓垨澶氫釜鍧楃敤浜庢煡璇㈢粨鏋滐級銆傚苟涓旓紝姣忎竴涓煡璇娇鐢ㄧ殑姣忎釜琛ㄩ渶瑕佷竴涓潡銆備絾鏄紝濡傛灉涓や釜鎴栧涓煡璇娇鐢ㄧ浉鍚岀殑琛紝浠呴渶瑕佸垎閰嶄竴涓潡銆
Qcache_lowmem_prunes鐘舵佸彉閲忔彁渚涚殑淇℃伅鑳藉甯姪浣犱綘璋冩暣鏌ヨ缂撳瓨鐨勫ぇ灏忋傚畠璁$畻涓轰簡缂撳瓨鏂扮殑鏌ヨ鑰屼粠鏌ヨ缂撳啿鍖轰腑绉诲嚭鍒拌嚜鐢卞唴瀛樹腑鐨勬煡璇㈢殑鏁扮洰銆傛煡璇㈢紦鍐插尯浣跨敤鏈杩戞渶灏戜娇鐢(LRU)绛栫暐鏉ョ‘瀹氬摢浜涙煡璇粠缂撳啿鍖轰腑绉诲嚭銆傝皟鏁翠俊鎭湪5.13.3鑺傦紝鈥滄煡璇㈤珮閫熺紦鍐查厤缃涓粰鍑恒
杩欐槸MySQL鍙傝冩墜鍐岀殑缈昏瘧鐗堟湰锛屽叧浜嶮ySQL鍙傝冩墜鍐岋紝璇疯闂dev.mysql.com銆 鍘熷鍙傝冩墜鍐屼负鑻辨枃鐗堬紝涓庤嫳鏂囩増鍙傝冩墜鍐岀浉姣旓紝鏈炕璇戠増鍙兘涓嶆槸鏈鏂扮殑銆