Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    63

    Unanswered: Syntax incorrect

    Hi folks,


    Have created a database 'maildb' and ran following steps entering data afterwards.


    mysql> use maildb;

    mysql> show tables;
    Code:
    +------------------+
    | Tables_in_maildb |
    +------------------+
    | aliases          | 
    | domains          | 
    | users            | 
    +------------------+
    3 rows in set (0.01 sec)
    Ran following command mistakenly;
    Code:
    mysql> INSERT INTO users (id,name,maildir,crypt) VALUES
        -> ('root@localhost','root','root/', encrypt('apassword') );
    Query OK, 1 row affected (0.00 sec)
    Then exit mysql.

    I should replace 'apassword' with the password used on other files, say 'abcde'.

    Following data have been set on "users"

    mysql> DESCRIBE users;
    Code:
    +-----------------+----------------------+------+-----+-------------------------+-------+
    | Field           | Type                 | Null | Key | Default                 | Extra |
    +-----------------+----------------------+------+-----+-------------------------+-------+
    | id              | varchar(128)         | NO   | PRI |                         |       | 
    | name            | varchar(128)         | NO   |     |                         |       | 
    | uid             | smallint(5) unsigned | NO   |     | 5000                    |       | 
    | gid             | smallint(5) unsigned | NO   |     | 5000                    |       | 
    | home            | varchar(255)         | NO   |     | /var/spool/mail/virtual |       | 
    | maildir         | varchar(255)         | NO   |     | blah/                   |       | 
    | enabled         | tinyint(3) unsigned  | NO   |     | 1                       |       | 
    | change_password | tinyint(3) unsigned  | NO   |     | 1                       |       | 
    | clear           | varchar(128)         | NO   |     | ChangeMe                |       | 
    | crypt           | varchar(128)         | NO   |     | sdtrusfX0Jj66           |       | 
    | quota           | varchar(255)         | NO   |     |                         |       | 
    | procmailrc      | varchar(128)         | NO   |     |                         |       | 
    | spamassassinrc  | varchar(128)         | NO   |     |                         |       | 
    +-----------------+----------------------+------+-----+-------------------------+-------+
    13 rows in set (0.00 sec)
    I tried to correct the mistake with the correct password by running following commands without result;

    mysql> UPDATE users SET crypt='apassword'('abcde') WHERE id='root@localhost';
    Code:
    ERROR 1064 (42000): 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 '('abcde') WHERE id='root@localhost'' at line 1
    mysql> UPDATE users SET crypt=encrypt('apassword')(encrypt('abcde')) WHERE id='root@localhost';
    Code:
    ERROR 1064 (42000): 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 '(encrypt('abcde')) WHERE id='root@localhost'' at line 1
    mysql> UPDATE users SET crypt='encrypt('apassword')'(encrypt('abcde')) WHERE id='root@localhost';
    Code:
    ERROR 1064 (42000): 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 'apassword')'(encrypt('abcde')) WHERE id='root@localhost'' at line 1
    etc.

    Please advise the correct syntax to be used. TIA


    B.R.
    satimis

  2. #2
    Join Date
    Aug 2005
    Posts
    30
    Try below query instead:-

    mysql> UPDATE users SET crypt=ENCRYPT('abcde') WHERE id='root@localhost';

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •