summaryrefslogtreecommitdiff
path: root/sql/mysql_install_db.cc
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2021-11-19 09:46:57 +0100
committerVladislav Vaintroub <wlad@mariadb.com>2021-11-19 09:46:57 +0100
commit010273268665746e188324e49730704c83aa8752 (patch)
tree57e441ab2a65be79e7e54755619518f9f4468c74 /sql/mysql_install_db.cc
parent220dc1fd59e61a44718a38ea59de5dc1da5aab8f (diff)
downloadmariadb-git-010273268665746e188324e49730704c83aa8752.tar.gz
Revert "MDEV-26713 Windows - improve utf8 support for command line tools"st-10.8-wlad
This reverts commit several commits pushed by mistake.
Diffstat (limited to 'sql/mysql_install_db.cc')
-rw-r--r--sql/mysql_install_db.cc28
1 files changed, 18 insertions, 10 deletions
diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc
index 925ff328564..f712e29b843 100644
--- a/sql/mysql_install_db.cc
+++ b/sql/mysql_install_db.cc
@@ -21,7 +21,6 @@
#include "mariadb.h"
#include <my_getopt.h>
#include <m_string.h>
-#include <password.h>
#include <windows.h>
#include <shellapi.h>
@@ -31,7 +30,6 @@
#include <sddl.h>
struct IUnknown;
#include <shlwapi.h>
-#include <winservice.h>
#include <string>
@@ -444,14 +442,16 @@ static int create_myini()
}
-static constexpr const char* update_root_passwd=
+static const char update_root_passwd_part1[]=
"UPDATE mysql.global_priv SET priv=json_set(priv,"
"'$.password_last_changed', UNIX_TIMESTAMP(),"
"'$.plugin','mysql_native_password',"
- "'$.authentication_string','%s') where User='root';\n";
-static constexpr char remove_default_user_cmd[]=
+ "'$.authentication_string',PASSWORD(";
+static const char update_root_passwd_part2[]=
+ ")) where User='root';\n";
+static const char remove_default_user_cmd[]=
"DELETE FROM mysql.user where User='';\n";
-static constexpr char allow_remote_root_access_cmd[]=
+static const char allow_remote_root_access_cmd[]=
"CREATE TEMPORARY TABLE tmp_user LIKE global_priv;\n"
"INSERT INTO tmp_user SELECT * from global_priv where user='root' "
" AND host='localhost';\n"
@@ -870,10 +870,18 @@ static int create_db_instance(const char *datadir)
/* Change root password if requested. */
if (opt_password && opt_password[0])
{
- verbose("Setting root password");
- char buf[2 * MY_SHA1_HASH_SIZE + 2];
- my_make_scrambled_password(buf, opt_password, strlen(opt_password));
- fprintf(in, update_root_passwd, buf);
+ verbose("Setting root password",remove_default_user_cmd);
+ fputs(update_root_passwd_part1, in);
+
+ /* Use hex encoding for password, to avoid escaping problems.*/
+ fputc('0', in);
+ fputc('x', in);
+ for(int i= 0; opt_password[i]; i++)
+ {
+ fprintf(in,"%02x",opt_password[i]);
+ }
+
+ fputs(update_root_passwd_part2, in);
fflush(in);
}