diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 0b31ca3a5ce..05abec9fe61 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -431,6 +431,7 @@ int main(int argc,char *argv[]) if (error > 0) break; + error= -error; /* don't exit with negative error codes */ /* Command was well-formed, but failed on the server. Might succeed on retry (if conditions on server change etc.), but needs --force @@ -1204,24 +1205,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) else if (mysql_query(mysql,buff)) { - if (mysql_errno(mysql)!=1290) - { - my_printf_error(0,"unable to change password; error: '%s'", - error_flags, mysql_error(mysql)); - } - else - { - /* - We don't try to execute 'update mysql.user set..' - because we can't perfectly find out the host - */ - my_printf_error(0,"\n" - "You cannot use 'password' command as mysqld runs\n" - " with grant tables disabled (was started with" - " --skip-grant-tables).\n" - "Use: \"mysqladmin flush-privileges password '*'\"" - " instead", error_flags); - } + my_printf_error(0,"unable to change password; error: '%s'", + error_flags, mysql_error(mysql)); ret = -1; } password_done: diff --git a/mysql-test/suite/plugins/r/simple_password_check.result b/mysql-test/suite/plugins/r/simple_password_check.result index c4f8d15fc51..3790bb8f8d8 100644 --- a/mysql-test/suite/plugins/r/simple_password_check.result +++ b/mysql-test/suite/plugins/r/simple_password_check.result @@ -250,3 +250,13 @@ Grants for foo1@localhost GRANT USAGE ON *.* TO `foo1`@`localhost` IDENTIFIED BY PASSWORD '*1D62FA326F98258451ED56A404F15452423DCC1D' drop user foo1@localhost; uninstall plugin simple_password_check; +# +# MDEV-22418 mysqladmin wrong error with simple_password_check +# +install soname "simple_password_check"; +MARIADB-ADMIN: unable to change password; error: 'The MariaDB server is running with the --strict-password-validation option so it cannot execute this statement' +# All done +uninstall plugin simple_password_check; +# +# End of 10.4 tests +# diff --git a/mysql-test/suite/plugins/t/simple_password_check.test b/mysql-test/suite/plugins/t/simple_password_check.test index 3ce2d86cd68..442585e89d4 100644 --- a/mysql-test/suite/plugins/t/simple_password_check.test +++ b/mysql-test/suite/plugins/t/simple_password_check.test @@ -150,3 +150,21 @@ flush privileges; show grants for foo1@localhost; drop user foo1@localhost; uninstall plugin simple_password_check; + + +--echo # +--echo # MDEV-22418 mysqladmin wrong error with simple_password_check +--echo # + +install soname "simple_password_check"; + +--replace_regex /.*[\/\\]// /(mysqladmin|mariadb-admin)(\.exe)?/MARIADB-ADMIN/ +--error 1 +--exec $MYSQLADMIN -uroot password foo 2>&1 + +--echo # All done +uninstall plugin simple_password_check; + +--echo # +--echo # End of 10.4 tests +--echo #