MySQL - Creating a user and specifying a password How do I create a user and specify a password in one line:

I thought CREATE USER 'foo'@'2.2.2.2' IDENTIFIED BY 'bar'; would do it but apparently it doesn't.

Any thoughts? I'm on version 5.1.49 of MySQL.
Your syntax is the good one :

[root@localhost] [(none)] mysql&gt; CREATE USER 'foo'@'2.2.2.2' IDENTIFIED BY 'bar';
Query OK, 0 rows affected (0.00 sec)


You can see if your user is created by using :

[root@localhost] [(none)] mysql&gt; show grants for 'foo'@'2.2.2.2';
+----------------------------------------------------------------------------------------------------------+
| Grants for foo@2.2.2.2                                                                                   |
+----------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'foo'@'2.2.2.2' IDENTIFIED BY PASSWORD '*E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB' |
+----------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)


But it'll work only if you connect from 2.2.2.2.

Max.