| 導購 | 订阅 | 在线投稿
分享
 
 
當前位置: 王朝網路 >> mysql >> 使用實例管理器輕松管理多個MySQL實例
 

使用實例管理器輕松管理多個MySQL實例

2008-06-01 03:23:19  編輯來源:互聯網  简体版  手機版  評論  字體: ||
 
 
  一、MySQL數據庫的實例管理器概述:

  1、MySQL數據庫的實例管理器(IM)是通過TCP/IP端口運行的後台程序,用來監視和管理MySQL數據庫服務器實例。

  2、假如IM挂了,則所有的實例都會挂掉;假如實例挂了,IM會嘗試重新來啓動它。

  3、IM讀取配置文件比如MY.CNF的[manager]段。

  4、本文中的示例依據LINUX環境下試驗。

  二、配置說明:

  1、配置文件如下:

  [manager]

  user=mysql

  default-mysqld-path = /usr/local/mysql/bin/mysqld

  socket=/tmp/manager.sock

  pid-file=/tmp/manager.pid

  password-file = /etc/mysqlmanager.passwd

  monitoring-interval = 2

  port = 1999

  bind-address = 192.168.0.231

  log = /usr/local/mysql/bin/mysqlmanager.log

  run-as-service = true

  [mysqld1]

  ...

  [mysqld2]

  ...

  這個有兩個配置實例,具體就不說了。見我的安裝多個實例的文章。

  具體含義查看mysqlmanager --help

  2、密碼文件

  IM將用戶信息保存到密碼文件中。密碼文件的默認位置爲/etc/mysqlmanager.passwd。

  密碼應類似于:

  petr:*35110DC9B4D8140F5DE667E28C72DD2597B5C848

  我的mysqlmanager.passwd內容

  user_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9

  3、啓動IM

  [root@localhost tmp]# /usr/local/mysql/bin/mysqlmanager

  WARNING: This program is deprecated and will be removed in 6.0.

  [2483/3086632640] [08/04/24 14:24:50] [INFO] IM: started.

  [2483/3086632640] [08/04/24 14:24:50] [INFO] Loading config file 'my.cnf'...

  [2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: initializing...

  [2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: detected threads model: POSIX threads.

  [2483/3086632640] [08/04/24 14:24:50] [INFO] Loading the password database...

  [2483/3086632640] [08/04/24 14:24:50] [INFO] Loaded user 'user_all'.

  [2483/3086632640] [08/04/24 14:24:50] [INFO] The password database loaded successfully.

  [2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: pid file (/tmp/manager.pid) created.

  [2483/3086632640] [08/04/24 14:24:50] [INFO] mysqld instance 'mysqld1' has been added successfully.

  [2483/3086632640] [08/04/24 14:24:50] [INFO] mysqld instance 'mysqld2' has been added successfully.

  [2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: started.

  [2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: starting 'mysqld1'...

  [2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: started.

  [2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: starting mysqld...

  [2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: starting 'mysqld2'...

  [2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: waiting for mysqld to stop...

  [2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: started.

  [2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: starting mysqld...

  [2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: waiting for mysqld to stop...

  [2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: started.

  [2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: started.

  [2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: accepting connections on ip socket (port: 1999)...

  [2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: accepting connections on unix socket '/tmp/manager.sock'...

  ...

  InnoDB: than specified in the .cnf file 0 5242880 bytes!

  080424 14:24:50 InnoDB: Started; log sequence number 0 46409

  080424 14:24:50 [Note] Event Scheduler: Loaded 0 events

  080424 14:24:50 [Note] /usr/local/mysql/bin/mysqld: ready for connections.

  Version: '5.1.23a-maria-alpha-log' socket: '/tmp/mysql1.sock' port: 3306 MySQL Community Server [Maria] (GPL)

  080424 14:24:50 [Warning] 'user' entry 'root@localhost.localdomain' ignored in --skip-name-resolve mode.

  080424 14:24:50 [Warning] 'user' entry '@localhost.localdomain' ignored in --skip-name-resolve mode.

  080424 14:24:50 [Note] Event Scheduler: Loaded 0 events

  080424 14:24:50 [Note] /usr/local/mysql/bin/mysqld: ready for connections.

  Version: '5.1.23a-maria-alpha-log' socket: '/tmp/mysql2.sock' port: 3309 MySQL Community Server [Maria] (GPL)

  [2483/3076139920] [08/04/24 14:24:52] [INFO] Guardian: 'mysqld1' is running, set state to STARTED.

  

  4、連接IM

  [root@localhost ~]# mysql -uuser_all -p -S/tmp/manager.sock -P1999

  三、用IM來管理MySQL數據庫

  1、顯示實例的狀態和版本信息

  [root@localhost ~]# mysql -uuser_all -p -S/tmp/manager.sock -P1999

  Enter password:

  Welcome to the MySQL monitor. Commands end with ; or \g.

  Your MySQL connection id is 1

  Server version: 1.0-beta

  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

  mysql> show instances;

  +---------------+--------+

  | instance_name | state |

  +---------------+--------+

  | mysqld1 | online |

  | mysqld2 | online |

  +---------------+--------+

  2 rows in set (0.00 sec)

  關閉實例1

  mysql> stop instance mysqld1;

  Query OK, 0 rows affected (0.30 sec)

  mysql> show instances;

  +---------------+---------+

  | instance_name | state |

  +---------------+---------+

  | mysqld1 | offline |

  | mysqld2 | online |

  +---------------+---------+

  2 rows in set (0.00 sec)

  開啓實例1

  mysql> start instance mysqld1;

  Query OK, 0 rows affected (0.00 sec)

  Instance started

  mysql> show instances;

  +---------------+--------+

  | instance_name | state |

  +---------------+--------+

  | mysqld1 | online |

  | mysqld2 | online |

  +---------------+--------+

  2 rows in set (0.00 sec)

  查看實例的版本信息

  mysql> show instance status mysqld2;

  +---------------+--------+----------------+

  | instance_name | state | version_number | version | mysqld_compatible |

  +---------------+--------+----------------+

  | mysqld2 | online | 5.1.23 | 5.1.23a-maria-alpha for redhat-linux-gnu on i686 (MySQL Community Server [Maria] (GPL))

  | no |

  +---------------+--------+----------------+

  1 row in set (0.00 sec)

  也可以顯示實例的選項信息

  mysql> show instance options mysqld1;

  +-----------------------+-----------------------------------+

  | option_name | value |

  +-----------------------+-----------------------------------+

  | instance_name | mysqld1 |

  | basedir | /usr/local/mysql |

  | datadir | /usr/local/mysql/data |

  | user | mysql |

  | default-character-set | utf8 |

  | port | 3306 |

  | socket | /tmp/mysql1.sock |

  | skip-locking | |

  | skip-name-resolve | |

  | key_buffer | 126M |

  | max_allowed_packet | 2M |

  | table_cache | 512 |

  | sort_buffer_size | 2M |

  | read_buffer_size | 2M |

  | read_rnd_buffer_size | 4M |

  | net_buffer_length | 2K |

  | thread_stack | 64K |

  | log-bin | mysql.log |

  | expire_logs_days | 5 |

  | wait_timeout | 20 |

  | pid-file | mysqld1-localhost.localdomain.pid |

  +-----------------------+-----------------------------------+

  21 rows in set (0.00 sec)

  也可以查詢實例的日志相關信,不再贅述。

  我們可以發現,管理實例其實非常方便。

  2、管理用戶

  (1)、添加管理用戶

  [root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --add-user

  WARNING: This program is deprecated and will be removed in 6.0.

  [3046/3086816960] [08/04/24 14:33:13] [INFO] IM: started.

  [3046/3086816960] [08/04/24 14:33:13] [INFO] Loading config file 'my.cnf'...

  Enter user name: shit_all

  [3046/3086816960] [08/04/24 14:33:18] [INFO] Loading the password database...

  [3046/3086816960] [08/04/24 14:33:18] [INFO] Loaded user 'user_all'.

  [3046/3086816960] [08/04/24 14:33:18] [INFO] The password database loaded successfully.

  Enter password:

  Re-type password:

  [3046/3086816960] [08/04/24 14:33:23] [INFO] IM: finished.

  [root@localhost ~]# cat /etc/mysqlmanager.passwd

  user_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9

  shit_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9

  注意:必須重新啓動IM才能生效。

  [root@localhost ~]# mysql -ushit_all -p -S/tmp/manager.sock -P1999

  Enter password:

  ERROR 1045 (28000): Access denied. Bad username/password pair

  (2)、修改用戶密碼

  [root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --edit-user

  WARNING: This program is deprecated and will be removed in 6.0.

  [3214/3086845632] [08/04/24 14:35:15] [INFO] IM: started.

  [3214/3086845632] [08/04/24 14:35:15] [INFO] Loading config file 'my.cnf'...

  Enter user name: shit_all

  [3214/3086845632] [08/04/24 14:35:19] [INFO] Loading the password database...

  [3214/3086845632] [08/04/24 14:35:19] [INFO] Loaded user 'user_all'.

  [3214/3086845632] [08/04/24 14:35:19] [INFO] Loaded user 'shit_all'.

  [3214/3086845632] [08/04/24 14:35:19] [INFO] The password database loaded successfully.

  Enter password:

  Re-type password:

  [3214/3086845632] [08/04/24 14:35:24] [INFO] IM: finished.

  

  (3)、刪除用戶

  [root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --drop-user

  WARNING: This program is deprecated and will be removed in 6.0.

  [3338/3086501568] [08/04/24 14:36:42] [INFO] IM: started.

  [3338/3086501568] [08/04/24 14:36:42] [INFO] Loading config file 'my.cnf'...

  Enter user name: shit_all

  [3338/3086501568] [08/04/24 14:36:45] [INFO] Loading the password database...

  [3338/3086501568] [08/04/24 14:36:45] [INFO] Loaded user 'user_all'.

  [3338/3086501568] [08/04/24 14:36:45] [INFO] Loaded user 'shit_all'.

  [3338/3086501568] [08/04/24 14:36:45] [INFO] The password database loaded successfully.

  [3338/3086501568] [08/04/24 14:36:45] [INFO] IM: finished.

  (4)、列出當前管理用戶

  [root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --list-user

  WARNING: This program is deprecated and will be removed in 6.0.

  [3366/3086087872] [08/04/24 14:37:07] [INFO] IM: started.

  [3366/3086087872] [08/04/24 14:37:07] [INFO] Loading config file 'my.cnf'...

  [3366/3086087872] [08/04/24 14:37:07] [INFO] Loading the password database...

  [3366/3086087872] [08/04/24 14:37:07] [INFO] Loaded user 'user_all'.

  [3366/3086087872] [08/04/24 14:37:07] [INFO] The password database loaded successfully.

  user_all

  [3366/3086087872] [08/04/24 14:37:07] [INFO] IM: finished.

  [root@localhost ~]#

  四、遠程管理

  C:\Documents and Settings\Administrator>mysql -uuser_all -p -P1999 -h192.168.0.2

  31

  Enter password: ******

  Welcome to the MySQL monitor. Commands end with ; or \g.

  Your MySQL connection id is 3

  Server version: 1.0-beta

  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

  mysql> show instances;

  +---------------+--------+

  | instance_name | state |

  +---------------+--------+

  | mysqld1 | online |

  | mysqld2 | online |

  +---------------+--------+

  2 rows in set (0.00 sec)

  mysql> quit

  總結:

  MySQL數據庫的實例管理器對于多個MySQL實例的管理是很方便的,但它本身存在兩個不足:

  1、不能直接進行數據庫的SQL管理命令。

  2、一定要確保IM進程不會突然挂掉。
 
 
 
上一篇《MySQL數據庫常見的出錯代碼及出錯信息》
下一篇《帶你輕松接觸MySQL數據庫的異常處理》
 
 
 
 
 
 
日版寵物情人插曲《Winding Road》歌詞

日版寵物情人2017的插曲,很帶節奏感,日語的,女生唱的。 最後聽見是在第8集的時候女主手割傷了,然後男主用嘴幫她吸了一下,插曲就出來了。 歌手:Def...

兄弟共妻,我成了他們夜裏的美食

老鍾家的兩個兒子很特別,就是跟其他的人不太一樣,魔一般的執著。兄弟倆都到了要結婚的年齡了,不管自家老爹怎麽磨破嘴皮子,兄弟倆說不娶就不娶,老父母爲兄弟兩操碎了心...

如何磨出破洞牛仔褲?牛仔褲怎麽剪破洞?

把牛仔褲磨出有線的破洞 1、具體工具就是磨腳石,下面墊一個硬物,然後用磨腳石一直磨一直磨,到把那塊磨薄了,用手撕開就好了。出來的洞啊很自然的。需要貓須的話調幾...

我就是掃描下圖得到了敬業福和愛國福

先來看下敬業福和愛國福 今年春節,支付寶再次推出了“五福紅包”活動,表示要“把欠大家的敬業福都還給大家”。 今天該活動正式啓動,和去年一樣,需要收集“五福”...

冰箱異味産生的原因和臭味去除的方法

有時候我們打開冰箱就會聞到一股異味,冰箱裏的這種異味是因爲一些物質發出的氣味的混合體,聞起來讓人惡心。 産生這些異味的主要原因有以下幾點。 1、很多人有這種習...

《極品家丁》1-31集大結局分集劇情介紹

簡介 《極品家丁》講述了現代白領林晚榮無意回到古代金陵,並追隨蕭二小姐化名“林三”進入蕭府,不料卻陰差陽錯上演了一出低級家丁拼搏上位的“林三升職記”。...

李溪芮《極品家丁》片尾曲《你就是我最愛的寶寶》歌詞

你就是我最愛的寶寶 - 李溪芮 (電視劇《極品家丁》片尾曲) 作詞:常馨內 作曲:常馨內 你的眉 又鬼馬的挑 你的嘴 又壞壞的笑 上一秒吵鬧 下...

烏梅的功效與作用以及烏梅的食用禁忌有哪些?

烏梅,又稱春梅,中醫認爲,烏梅味酸,性溫,無毒,具有安心、除熱、下氣、祛痰、止渴調中、殺蟲的功效,治肢體痛、肺痨病。烏梅泡水喝能治傷寒煩熱、止吐瀉,與幹姜一起制...

什麽是脂肪粒?如何消除臉部脂肪粒?

什麽是脂肪粒 在我們的臉上總會長一個個像脂肪的小顆粒,弄也弄不掉,而且顔色還是白白的。它既不是粉刺也不是其他的任何痘痘,它就是脂肪粒。 脂肪粒雖然也是由油脂...

網絡安全治理:國家安全保障的主要方向是打擊犯罪,而不是處置和懲罰受害者

來源:中國青年報 新的攻擊方法不斷湧現,黑客幾乎永遠占據網絡攻擊的上風,我們不可能通過技術手段杜絕網絡攻擊。國家安全保障的主要方向是打擊犯罪,而不是處置和懲罰...

河南夫妻在溫嶺網絡直播“造人”內容涉黃被刑事拘留

夫妻網絡直播“造人”爆紅   1月9日,溫嶺城北派出所接到南京警方的協查通告,他們近期打掉了一個涉黃直播APP平台。而根據掌握的線索,其中有一對涉案的夫妻主播...

如何防止牆紙老化?牆紙變舊變黃怎麽辦?

如何防止牆紙老化? (1)選擇透氣性好的牆紙 市場上牆紙的材質分無紡布的、木纖維的、PVC的、玻璃纖維基材的、布面的等,相對而言,PVC材質的牆紙最不透氣...

鮮肌之謎非日本生産VS鮮肌之謎假日貨是謠言

觀點一:破日本銷售量的“鮮肌之謎” 非日本生産 近一段時間,淘寶上架了一款名爲“鮮肌之謎的” 鲑魚卵巢美容液,號稱是最近日本的一款推出的全新護膚品,産品本身所...

中國最美古詩詞精選摘抄

系腰裙(北宋詞人 張先) 惜霜蟾照夜雲天,朦胧影、畫勾闌。人情縱似長情月,算一年年。又能得、幾番圓。 欲寄西江題葉字,流不到、五亭前。東池始有荷新綠,尚小如...

關于女人的經典語句

關于女人的經典語句1、【做一個獨立的女人】 思想獨立:有主見、有自己的人生觀、價值觀。有上進心,永遠不放棄自己的理想,做一份自己喜愛的事業,擁有快樂和成就...

未來我們可以和性愛機器人結婚嗎?

你想體驗機器人性愛嗎?你想和性愛機器人結婚嗎?如果你想,機器人有拒絕你的權利嗎? 近日,第二屆“國際人類-機器人性愛研討會”大會在倫敦金史密斯大學落下帷幕。而...

全球最變態的十個地方

10.土耳其地下洞穴城市 變態指數:★★☆☆☆ 這是土耳其卡帕多西亞的一個著名景點,傳說是當年基督教徒們爲了躲避戰爭而在此修建。裏面曾住著20000人,...

科學家稱,人類死亡後意識將在另外一個宇宙中繼續存活

據英國《每日快報》報道,一位科學家兼理論家Robert Lanza博士宣稱,世界上並不存在人類死亡,死亡的只是身體。他認爲我們的意識借助我們體內的能量生存,而且...

《屏裏狐》片頭曲《我愛狐狸精》歌詞是什麽?

《我愛狐狸精》 - 劉馨棋   (電視劇《屏裏狐》主題曲)   作詞:金十三&李旦   作曲:劉嘉   狐狸精 狐狸仙   千年修...

 
 
 
一、MySQL數據庫的實例管理器概述: 1、MySQL數據庫的實例管理器(IM)是通過TCP/IP端口運行的後台程序,用來監視和管理MySQL數據庫服務器實例。 2、假如IM挂了,則所有的實例都會挂掉;假如實例挂了,IM會嘗試重新來啓動它。 3、IM讀取配置文件比如MY.CNF的[manager]段。 4、本文中的示例依據LINUX環境下試驗。 二、配置說明: 1、配置文件如下: [manager] user=mysql default-mysqld-path = /usr/local/mysql/bin/mysqld socket=/tmp/manager.sock pid-file=/tmp/manager.pid password-file = /etc/mysqlmanager.passwd monitoring-interval = 2 port = 1999 bind-address = 192.168.0.231 log = /usr/local/mysql/bin/mysqlmanager.log run-as-service = true [mysqld1] ... [mysqld2] ... 這個有兩個配置實例,具體就不說了。見我的安裝多個實例的文章。 具體含義查看mysqlmanager --help 2、密碼文件 IM將用戶信息保存到密碼文件中。密碼文件的默認位置爲/etc/mysqlmanager.passwd。 密碼應類似于: petr:*35110DC9B4D8140F5DE667E28C72DD2597B5C848 我的mysqlmanager.passwd內容 user_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 3、啓動IM [root@localhost tmp]# /usr/local/mysql/bin/mysqlmanager WARNING: This program is deprecated and will be removed in 6.0. [2483/3086632640] [08/04/24 14:24:50] [INFO] IM: started. [2483/3086632640] [08/04/24 14:24:50] [INFO] Loading config file 'my.cnf'... [2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: initializing... [2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: detected threads model: POSIX threads. [2483/3086632640] [08/04/24 14:24:50] [INFO] Loading the password database... [2483/3086632640] [08/04/24 14:24:50] [INFO] Loaded user 'user_all'. [2483/3086632640] [08/04/24 14:24:50] [INFO] The password database loaded successfully. [2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: pid file (/tmp/manager.pid) created. [2483/3086632640] [08/04/24 14:24:50] [INFO] mysqld instance 'mysqld1' has been added successfully. [2483/3086632640] [08/04/24 14:24:50] [INFO] mysqld instance 'mysqld2' has been added successfully. [2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: started. [2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: starting 'mysqld1'... [2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: started. [2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: starting mysqld... [2483/3076139920] [08/04/24 14:24:50] [INFO] Guardian: starting 'mysqld2'... [2483/3076058000] [08/04/24 14:24:50] [INFO] Instance 'mysqld1': Monitor: waiting for mysqld to stop... [2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: started. [2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: starting mysqld... [2483/3075894160] [08/04/24 14:24:50] [INFO] Instance 'mysqld2': Monitor: waiting for mysqld to stop... [2483/3086632640] [08/04/24 14:24:50] [INFO] Manager: started. [2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: started. [2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: accepting connections on ip socket (port: 1999)... [2483/3075976080] [08/04/24 14:24:50] [INFO] Listener: accepting connections on unix socket '/tmp/manager.sock'... ... InnoDB: than specified in the .cnf file 0 5242880 bytes! 080424 14:24:50 InnoDB: Started; log sequence number 0 46409 080424 14:24:50 [Note] Event Scheduler: Loaded 0 events 080424 14:24:50 [Note] /usr/local/mysql/bin/mysqld: ready for connections. Version: '5.1.23a-maria-alpha-log' socket: '/tmp/mysql1.sock' port: 3306 MySQL Community Server [Maria] (GPL) 080424 14:24:50 [Warning] 'user' entry 'root@localhost.localdomain' ignored in --skip-name-resolve mode. 080424 14:24:50 [Warning] 'user' entry '@localhost.localdomain' ignored in --skip-name-resolve mode. 080424 14:24:50 [Note] Event Scheduler: Loaded 0 events 080424 14:24:50 [Note] /usr/local/mysql/bin/mysqld: ready for connections. Version: '5.1.23a-maria-alpha-log' socket: '/tmp/mysql2.sock' port: 3309 MySQL Community Server [Maria] (GPL) [2483/3076139920] [08/04/24 14:24:52] [INFO] Guardian: 'mysqld1' is running, set state to STARTED. 4、連接IM [root@localhost ~]# mysql -uuser_all -p -S/tmp/manager.sock -P1999 三、用IM來管理MySQL數據庫 1、顯示實例的狀態和版本信息 [root@localhost ~]# mysql -uuser_all -p -S/tmp/manager.sock -P1999 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 1.0-beta Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show instances; +---------------+--------+ | instance_name | state | +---------------+--------+ | mysqld1 | online | | mysqld2 | online | +---------------+--------+ 2 rows in set (0.00 sec) 關閉實例1 mysql> stop instance mysqld1; Query OK, 0 rows affected (0.30 sec) mysql> show instances; +---------------+---------+ | instance_name | state | +---------------+---------+ | mysqld1 | offline | | mysqld2 | online | +---------------+---------+ 2 rows in set (0.00 sec) 開啓實例1 mysql> start instance mysqld1; Query OK, 0 rows affected (0.00 sec) Instance started mysql> show instances; +---------------+--------+ | instance_name | state | +---------------+--------+ | mysqld1 | online | | mysqld2 | online | +---------------+--------+ 2 rows in set (0.00 sec) 查看實例的版本信息 mysql> show instance status mysqld2; +---------------+--------+----------------+ | instance_name | state | version_number | version | mysqld_compatible | +---------------+--------+----------------+ | mysqld2 | online | 5.1.23 | 5.1.23a-maria-alpha for redhat-linux-gnu on i686 (MySQL Community Server [Maria] (GPL)) | no | +---------------+--------+----------------+ 1 row in set (0.00 sec) 也可以顯示實例的選項信息 mysql> show instance options mysqld1; +-----------------------+-----------------------------------+ | option_name | value | +-----------------------+-----------------------------------+ | instance_name | mysqld1 | | basedir | /usr/local/mysql | | datadir | /usr/local/mysql/data | | user | mysql | | default-character-set | utf8 | | port | 3306 | | socket | /tmp/mysql1.sock | | skip-locking | | | skip-name-resolve | | | key_buffer | 126M | | max_allowed_packet | 2M | | table_cache | 512 | | sort_buffer_size | 2M | | read_buffer_size | 2M | | read_rnd_buffer_size | 4M | | net_buffer_length | 2K | | thread_stack | 64K | | log-bin | mysql.log | | expire_logs_days | 5 | | wait_timeout | 20 | | pid-file | mysqld1-localhost.localdomain.pid | +-----------------------+-----------------------------------+ 21 rows in set (0.00 sec) 也可以查詢實例的日志相關信,不再贅述。 我們可以發現,管理實例其實非常方便。 2、管理用戶 (1)、添加管理用戶 [root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --add-user WARNING: This program is deprecated and will be removed in 6.0. [3046/3086816960] [08/04/24 14:33:13] [INFO] IM: started. [3046/3086816960] [08/04/24 14:33:13] [INFO] Loading config file 'my.cnf'... Enter user name: shit_all [3046/3086816960] [08/04/24 14:33:18] [INFO] Loading the password database... [3046/3086816960] [08/04/24 14:33:18] [INFO] Loaded user 'user_all'. [3046/3086816960] [08/04/24 14:33:18] [INFO] The password database loaded successfully. Enter password: Re-type password: [3046/3086816960] [08/04/24 14:33:23] [INFO] IM: finished. [root@localhost ~]# cat /etc/mysqlmanager.passwd user_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 shit_all:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 注意:必須重新啓動IM才能生效。 [root@localhost ~]# mysql -ushit_all -p -S/tmp/manager.sock -P1999 Enter password: ERROR 1045 (28000): Access denied. Bad username/password pair (2)、修改用戶密碼 [root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --edit-user WARNING: This program is deprecated and will be removed in 6.0. [3214/3086845632] [08/04/24 14:35:15] [INFO] IM: started. [3214/3086845632] [08/04/24 14:35:15] [INFO] Loading config file 'my.cnf'... Enter user name: shit_all [3214/3086845632] [08/04/24 14:35:19] [INFO] Loading the password database... [3214/3086845632] [08/04/24 14:35:19] [INFO] Loaded user 'user_all'. [3214/3086845632] [08/04/24 14:35:19] [INFO] Loaded user 'shit_all'. [3214/3086845632] [08/04/24 14:35:19] [INFO] The password database loaded successfully. Enter password: Re-type password: [3214/3086845632] [08/04/24 14:35:24] [INFO] IM: finished. (3)、刪除用戶 [root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --drop-user WARNING: This program is deprecated and will be removed in 6.0. [3338/3086501568] [08/04/24 14:36:42] [INFO] IM: started. [3338/3086501568] [08/04/24 14:36:42] [INFO] Loading config file 'my.cnf'... Enter user name: shit_all [3338/3086501568] [08/04/24 14:36:45] [INFO] Loading the password database... [3338/3086501568] [08/04/24 14:36:45] [INFO] Loaded user 'user_all'. [3338/3086501568] [08/04/24 14:36:45] [INFO] Loaded user 'shit_all'. [3338/3086501568] [08/04/24 14:36:45] [INFO] The password database loaded successfully. [3338/3086501568] [08/04/24 14:36:45] [INFO] IM: finished. (4)、列出當前管理用戶 [root@localhost ~]# /usr/local/mysql/bin/mysqlmanager --list-user WARNING: This program is deprecated and will be removed in 6.0. [3366/3086087872] [08/04/24 14:37:07] [INFO] IM: started. [3366/3086087872] [08/04/24 14:37:07] [INFO] Loading config file 'my.cnf'... [3366/3086087872] [08/04/24 14:37:07] [INFO] Loading the password database... [3366/3086087872] [08/04/24 14:37:07] [INFO] Loaded user 'user_all'. [3366/3086087872] [08/04/24 14:37:07] [INFO] The password database loaded successfully. user_all [3366/3086087872] [08/04/24 14:37:07] [INFO] IM: finished. [root@localhost ~]# 四、遠程管理 C:\Documents and Settings\Administrator>mysql -uuser_all -p -P1999 -h192.168.0.2 31 Enter password: ****** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 1.0-beta Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show instances; +---------------+--------+ | instance_name | state | +---------------+--------+ | mysqld1 | online | | mysqld2 | online | +---------------+--------+ 2 rows in set (0.00 sec) mysql> quit 總結: MySQL數據庫的實例管理器對于多個MySQL實例的管理是很方便的,但它本身存在兩個不足: 1、不能直接進行數據庫的SQL管理命令。 2、一定要確保IM進程不會突然挂掉。
󰈣󰈤
 
 
 
  免責聲明:本文僅代表作者個人觀點,與王朝網路無關。王朝網路登載此文出於傳遞更多信息之目的,並不意味著贊同其觀點或證實其描述,其原創性以及文中陳述文字和內容未經本站證實,對本文以及其中全部或者部分內容、文字的真實性、完整性、及時性本站不作任何保證或承諾,請讀者僅作參考,並請自行核實相關內容。
 
 
美得讓人陶醉
杭州美女模特米萊
清純迷人唐小妹
氣質一流的上海女生
夢醉克孜加爾湖畔
珠江公園(二)
魔域桃源
南嶺森林公園親水谷
 
>>返回首頁<<
 
 
 
 熱帖排行
 
 
 
 
© 2005- 王朝網路 版權所有