Unsupported Screen Size: The viewport size is too small for the theme to render properly.

Create User With @variable For The Password

forums forums SQLyog Using SQLyog Create User With @variable For The Password

  • This topic is empty.
Viewing 2 reply threads
  • Author
    Posts
    • #12587
      larsen
      Participant

      Hi,

      I want to create a user with the password from another user like this:

      SELECT PASSWORD FROM USER WHERE USER = ‘jon’ INTO @var;

      CREATE USER ‘jane’@'localhost’ IDENTIFIED BY PASSWORD @var;

      Unfortunately, this only gives me “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘@var’ at line 1″.

      I have tried other ways but didn´t succeed. Is what I´m trying to do even possible?

      Lars

    • #33103
      peterlaursen
      Participant

      As far as I can understand the first statement will save a HASHED password into a user variable. In CREATE USER you shall not specify a hashed password but a clear-text password.

      Also there is a bug report here http://bugs.mysql.com/bug.php?id=28406 that I understand that ” … IDENTIFIED BY @uservar” is not accepted by the server in CREATE USER.

      What about something like

      Code:
      SELECT PASSWORD FROM USER WHERE USER = 'jon' INTO @var;

      INSERT INTO USER (user, host, password) VALUES ('jane','localhost',@var);

      FLUSH PRIVILEGES:

      (Note that the 2nd statement will fail in 'strict mode'. In 'strict mode' you will need to specify empty string defaults for all BLOB and TEXT columns in the user table. But SQLyog runs in non-strict mode as default).

    • #33104
      larsen
      Participant

      Thanks for the bug ID. I thought that this must be possible so I didn´t even bother to search for it.

      'peterlaursen' wrote:

      As far as I can understand the first statement will save a HASHED password into a user variable. In CREATE USER you shall not specify a hashed password but a clear-text password.

      Yes, that´s right. I just want to duplicate an account for another IP without the need to lookup the password. This is necessary when configuring a dedicated server and I want to automate as much as possible so I just have to execute the commands (via copy&paste) and not type anything manually. Therefore, I simply copy the hash value.

      Thanks for the workaround! Had almost forgotten about that way 😉

Viewing 2 reply threads
  • You must be logged in to reply to this topic.