Mydumper need to enter plaintext password solution in Linux

Source: Internet
Author: User
Tags commit diff sprintf strlen

When using Mydumper, you need to enter the username and password in the command line, which is recorded in the history, which is relatively insecure.
[Root@liufofu backup]# mydumper-h localhost-u root-p tiger-c-O./liufofu/-B Liufofu
There are 2 types of official solutions available:
1. Create a new one in Homedir. my.cfg, enter your user and password
2, hit the corresponding patch
You can refer to the official reply
1. Use ~/.MY.CFG with your login and password to authenticate. It'll both not save password in bash history and hide password if PS list, but you'll have to keep plaintext 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 @@ -367,6 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 @@ -377,6 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 is 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 @@ -93,6 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 @@ -104,6 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

Contact Us

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

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

A Free Trial That Lets You Build Big!

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

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

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