Reputation: 12779
I tried using the "create user" command in a MySQL4 database (something similar to what is available in the MySQL5 docs), but it failed. Can someone provide me the right syntax?
Upvotes: 1
Views: 7608
Reputation: 23493
Users are created the first time you GRANT
them a privilege.
From http://dev.mysql.com/doc/refman/4.1/en/grant.html :
The GRANT statement creates MySQL user accounts and grants rights to accounts.
So, let's say you have a database "mydb", with a table "mytable". If you want to create a user "jason", with the password "pwd123!" who has SELECT privileges on this table, you can do this:
grant select on mydb.mytable to 'jason'@'hostname' identified by 'pwd123!';
The usual caveats about hostname apply.
If you want to give jason full permissions on mydb:
grant all on mydb.* to 'jason'@'hostname' identified by 'pwd123!';
Important note: every time you use identified by
, you're changing the password for that user/hostname, so you you will typically only use this syntax when creating a user!
Upvotes: 3