fixed bug #3160 '"mysqladmin password" doesn't work if --skip-grant-tables'

parent 36120d42
...@@ -786,11 +786,32 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) ...@@ -786,11 +786,32 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
return -1; return -1;
} }
if (mysql_query(mysql,buff)) if (mysql_query(mysql,buff))
{
if (mysql_errno(mysql)!=1290)
{ {
my_printf_error(0,"unable to change password; error: '%s'", my_printf_error(0,"unable to change password; error: '%s'",
MYF(ME_BELL),mysql_error(mysql)); MYF(ME_BELL),mysql_error(mysql));
return -1; return -1;
} }
else
{
sprintf(buff,"UPDATE mysql.user SET password='%s' WHERE user='%s' and"
" host=substring_index(user(),_utf8\"@\",-1)",
crypted_pw, user);
if (mysql_query(mysql,buff))
{
my_printf_error(0,"unable to update user table; error: '%s'",
MYF(ME_BELL),mysql_error(mysql));
return -1;
}
if (mysql_query(mysql,"set sql_log_off=0"))
{
my_printf_error(0, "Can't turn on logging; error: '%s'",
MYF(ME_BELL),mysql_error(mysql));
return -1;
}
}
}
argc--; argv++; argc--; argv++;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment