linux中mydumper需要輸入純文字密碼解決方案

來源:互聯網
上載者:User

在使用mydumper時,需要再命令列中輸入使用者名稱和密碼,這會記錄到history中,這樣的話,就是相對不安全。
[root@liufofu backup]# mydumper -h localhost -u root -p tiger -c -o ./liufofu/ -B liufofu
查了下官方提供的解決方案有2種:
1、在homedir中建立一個.my.cfg,輸入你的使用者和密碼
2、打上相應的補丁
具體可以參考官方的回複
1. Use ~/.my.cfg with your login and password to authenticate. It will both not save password in bash history and hide password if ps list, but you’ll have to keep plaintext password in your homedir.
2. Try this patch
commit 056fa3edc2a3880d35986d6f123430fde5fe292a
Author: Dmitry Ilyin <email address hidden>
Date: Sat Oct 27 02:10:40 2012 +0400
Add cmdline mask for mydumper
diff –git a/mydumper.c b/mydumper.c
index 9c37d39..39edff1 100644
— a/mydumper.c
+++ b/mydumper.c
@@ -367,6 +367,15 @@ int main(int argc, char *argv[])
init_mutex = g_mutex_new();
+ //calculate cmdlen
+ int cmdlen = 0;
+ int argn = 0;
+
+ for (argn = 0; argn < argc; ++argn) {
+ cmdlen += (int) strlen(argv[argn]);
+ }
+ cmdlen = cmdlen + argc – 1;
+
context = g_option_context_new(“multi-threaded MySQL dumping”);
 GOptionGroup *main_group= g_option_group_new(“main”, “Main Options”, “Main Options”, NULL, NULL);
 g_option_group_add_entries(main_group, entries);
@@ -377,6 +386,11 @@ int main(int argc, char *argv[])
         exit (EXIT_FAILURE);
}
 g_option_context_free(context);
+
+ //erase cmdline
+ memset(argv[0],’\0′,cmdlen);
+ //set new cmdline
+ sprintf(argv[0],”mydumper: dumping database ‘%s’”,db);
if (program_version) {
         g_print(“mydumper %s, built against MySQL %s\n”, VERSION, MYSQL_SERVER_VERSION);
——-
and this for my loader
——-
commit f8f9850045a317b927903482317ee32ecce47eea
Author: Dmitry Ilyin <email address hidden>
Date: Sat Oct 27 02:24:33 2012 +0400
Add cmdline mask for myloader
diff –git a/myloader.c b/myloader.c
index 7697e97..a38b4fd 100644
— a/myloader.c
+++ b/myloader.c
@@ -93,6 +93,15 @@ int main(int argc, char *argv[]) {
init_mutex= g_mutex_new();
+ //calculate cmdlen
+ int cmdlen = 0;
+ int argn = 0;
+
+ for (argn = 0; argn < argc; ++argn) {
+ cmdlen += (int) strlen(argv[argn]);
+ }
+ cmdlen = cmdlen + argc – 1;
+
context= g_option_context_new(“multi-threaded MySQL loader”);
 GOptionGroup *main_group= g_option_group_new(“main”, “Main Options”, “Main Options”, NULL, NULL);
 g_option_group_add_entries(main_group, entries);
@@ -104,6 +113,11 @@ int main(int argc, char *argv[]) {
}
 g_option_context_free(context);
+ //erase cmdline
+ memset(argv[0],’\0′,cmdlen);
+ //set new cmdline
+ sprintf(argv[0],”myloader: loading from directory ‘%s’”,directory);
+
if (program_version) {
         g_print(“myloader %s, built against MySQL %s\n”, VERSION, MYSQL_SERVER_VERSION);
         exit(EXIT_SUCCESS);
—-
They hide password and other arguments from ps list

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

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

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