mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 11:17:57 +08:00
Use CREATE USER query for added users, as required since 5.0.2 servers when password is empty. Works around SQL error 1133 (Can't find any matching row in the user table). See http://www.heidisql.com/forum.php?t=6948
This commit is contained in:
@ -766,10 +766,11 @@ end;
|
|||||||
procedure TUserManagerForm.btnSaveClick(Sender: TObject);
|
procedure TUserManagerForm.btnSaveClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
Conn: TMySQLConnection;
|
Conn: TMySQLConnection;
|
||||||
UserHost, NewUserHost, Table, Revoke, Grant, OnObj: String;
|
UserHost, NewUserHost, Create, Table, Revoke, Grant, OnObj: String;
|
||||||
Tables: TStringList;
|
Tables: TStringList;
|
||||||
P: TPrivObj;
|
P: TPrivObj;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
PasswordSet: Boolean;
|
||||||
begin
|
begin
|
||||||
// Save changes
|
// Save changes
|
||||||
Conn := MainForm.ActiveConnection;
|
Conn := MainForm.ActiveConnection;
|
||||||
@ -793,6 +794,16 @@ begin
|
|||||||
if editPassword.Text <> editRepeatPassword.Text then
|
if editPassword.Text <> editRepeatPassword.Text then
|
||||||
raise EInputError.Create('Repeated password does not match first one.');
|
raise EInputError.Create('Repeated password does not match first one.');
|
||||||
|
|
||||||
|
// Create added user
|
||||||
|
PasswordSet := False;
|
||||||
|
if FAdded and (Conn.ServerVersionInt >= 50002) then begin
|
||||||
|
Create := 'CREATE USER '+UserHost;
|
||||||
|
if editPassword.Modified then
|
||||||
|
Create := Create + ' IDENTIFIED BY '+esc(editPassword.Text);
|
||||||
|
Conn.Query(Create);
|
||||||
|
PasswordSet := True;
|
||||||
|
end;
|
||||||
|
|
||||||
// Grant added privileges and revoke deleted ones
|
// Grant added privileges and revoke deleted ones
|
||||||
for P in FPrivObjects do begin
|
for P in FPrivObjects do begin
|
||||||
|
|
||||||
@ -847,7 +858,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Set password
|
// Set password
|
||||||
if editPassword.Modified then begin
|
if editPassword.Modified and (not PasswordSet) then begin
|
||||||
Conn.Query('SET PASSWORD FOR ' + UserHost + ' = PASSWORD('+esc(editPassword.Text)+')');
|
Conn.Query('SET PASSWORD FOR ' + UserHost + ' = PASSWORD('+esc(editPassword.Text)+')');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user