LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Error in SQL Query.. (https://www.linuxquestions.org/questions/linux-software-2/error-in-sql-query-525197/)

gobi_dgm 02-03-2007 04:38 AM

Error in SQL Query..
 
Hi,
Im trying to create a user in mysql as root user. Im getting an error as given below.

shell> CREATE USER david PASSWORD blue ;
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 'USER david PASSWORD' at line 1

Using mysql-4.1. i checked the manual and found this syntax to be correct. Couldn find the problem? Please someone help me in this..

Thanks
Gobi

tredegar 02-03-2007 09:41 AM

You need to read the mysql reference manual:

http://dev.mysql.com/doc/refman/5.0/en/

Quote:

13.5.1.1. CREATE USER Syntax

CREATE USER user [IDENTIFIED BY [PASSWORD] 'password']
[, user [IDENTIFIED BY [PASSWORD] 'password']] ...


The CREATE USER statement was added in MySQL 5.0.2. This statement creates new MySQL accounts. To use it, you must have the global CREATE USER privilege or the INSERT privilege for the mysql database. For each account, CREATE USER creates a new record in the mysql.user table that has no privileges. An error occurs if the account already exists. Each account is named using the same format as for the GRANT statement; for example, 'jeffrey'@'localhost'. If you specify only the username part of the account name, a hostname part of '%' is used. For additional information about specifying account names, see Section 13.5.1.3, “GRANT Syntax”.

The account can be given a password with the optional IDENTIFIED BY clause. The user value and the password are given the same way as for the GRANT statement. In particular, to specify the password in plain text, omit the PASSWORD keyword. To specify the password as the hashed value as returned by the PASSWORD() function, include the PASSWORD keyword. See Section 13.5.1.3, “GRANT Syntax”.
So, your command should be:

CREATE USER david IDENTIFIED BY 'blue'


All times are GMT -5. The time now is 02:19 PM.